So I have a MVC5 web application and I'm using the built in ASP.Identity framework for authentication. I want to let my user keep their login status for 30 days.
here's my code in Startup.Auth.cs
:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
CookieName = "Test",
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromDays(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
},
ExpireTimeSpan = TimeSpan.FromDays(30)
});
I checked the cookie after login and it's true that the expiration is 30 days, but after few minutes/hours when I'm trying to access the site again, the login status is gone. Any idea why?