AppHarbor.Web.Security.AuthenticationCookie.IsExpired C# (CSharp) Method

IsExpired() public method

public IsExpired ( System.TimeSpan validity ) : bool
validity System.TimeSpan
return bool
		public bool IsExpired(TimeSpan validity)
		{
			return _issueDate.Add(validity) <= DateTime.UtcNow;
		}

Usage Example

		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);
		}
All Usage Examples Of AppHarbor.Web.Security.AuthenticationCookie::IsExpired