It seems I don't understand clearly how IsPersistent
in OWIN cookie authentication works, the code below is to use IsPersistent
:
var context = Request.GetOwinContext();
var authManager = context.Authentication;
var properties = new AuthenticationProperties { IsPersistent = isPersistence };
authManager.SignIn(properties, identity);
I don't see the difference when user checks/unchecks Remember me
(uses IsPersistent
behind) because if I close Chrome browser and open it again to go with the website, the cookie .AspNet.ApplicationCookie
is still there and it lets me in even I check or uncheck Remember me
.
I have checked the definition of IsPersistent
on the link:
Gets or sets whether the authentication session is persisted across multiple requests.
But don't get much understanding since I see it still works.
The code to setup OWIN cookie authentication:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationMode = AuthenticationMode.Active,
AuthenticationType = ApplicationTypes.ApplicationCookie,
ExpireTimeSpan = TimeSpan.FromMinutes(30),
LoginPath = new PathString("/Account/LogOn")
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…