private static void RenewCookieIfExpiring(HttpContextBase 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 = authenticationCookie.CreateHttpCookie(protector, Configuration); context.Response.Cookies.Add(newCookie); }
private static void RenewCookieIfExpiring(IOwinResponse response, CookieProtector protector, AuthenticationCookie authenticationCookie) { if (!Configuration.SlidingExpiration || !authenticationCookie.IsExpired(TimeSpan.FromTicks(Configuration.Timeout.Ticks / 2))) { return; } authenticationCookie.Renew(); response.Cookies.Delete(Configuration.CookieName); var newCookie = authenticationCookie.CreateHttpCookie(protector, Configuration); response.Cookies.Append(Configuration.CookieName, newCookie.Value, new CookieOptions { Domain = newCookie.Domain, Expires = newCookie.Expires, HttpOnly = newCookie.HttpOnly, Path = newCookie.Path, Secure = newCookie.Secure }); }