AppHarbor.Web.Security.CookieAuthenticationModule.RenewCookieIfExpiring C# (CSharp) Method

RenewCookieIfExpiring() private method

private RenewCookieIfExpiring ( HttpContext context, CookieProtector protector, AuthenticationCookie authenticationCookie ) : void
context System.Web.HttpContext
protector CookieProtector
authenticationCookie AuthenticationCookie
return void
		private void RenewCookieIfExpiring(HttpContext context, CookieProtector protector, AuthenticationCookie authenticationCookie)
		{
			if (!_configuration.SlidingExpiration || !authenticationCookie.IsExpired(TimeSpan.FromTicks(_configuration.Timeout.Ticks / 2)))
			{
				return;
			}
			authenticationCookie.Renew();
			context.Response.Cookies.Remove(_configuration.CookieName);
			var newCookie = new HttpCookie(_configuration.CookieName, protector.Protect(authenticationCookie.Serialize()))
			{
				HttpOnly = true,
				Secure = _configuration.RequireSSL,
			};
            if (!string.IsNullOrEmpty(_configuration.Domain))
            {
                newCookie.Domain = _configuration.Domain;
            }
            var expireDateTime = authenticationCookie.IssueDate + _configuration.Timeout;
            if (authenticationCookie.Persistent)
            {
                newCookie.Expires = expireDateTime;
            }
			context.Response.Cookies.Add(newCookie);

            RenewTrackExpireTimeCookie(context, expireDateTime);
		}