Environment: ASP.NET Core 2.0, Identity with cookies.
In Startup.ConfigureServices()
there is this:
services.ConfigureApplicationCookie(opti
This code workds for me. Only second block changes cookie expiration
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
// Cookie settings
options.Cookie.HttpOnly = true;
options.Cookie.SameSite = SameSiteMode.Strict;
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
options.LoginPath = "/Account/Login";
options.LogoutPath = "/Account/Logout";
options.AccessDeniedPath = "/Account/AccessDenied";
});
services.ConfigureApplicationCookie(options =>
{
// Cookie settings, only this changes expiration
options.Cookie.HttpOnly = true;
options.Cookie.Expiration = TimeSpan.FromDays(150);
options.ExpireTimeSpan = TimeSpan.FromDays(150);
});