I'm having an issue while trying to set the expire time of a cookie in my CookieAuthentication
, it seems that ExpireTimeSpan
is just ignored and when i get the cookie in the browser it's expire time is set to Session
..
I'm using c# 8.0 w/ .NET Core 3.1 and here is my ConfigureService
code:
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options => {
options.Cookie.Name = "authToken";
options.ExpireTimeSpan = TimeSpan.FromMinutes(120);
options.Events = new CookieAuthenticationEvents()
{
OnRedirectToLogin = (context) =>
{
context.HttpContext.Response.Redirect("https://example.com/test/expired.html");
return Task.CompletedTask;
}
};
});
services.AddControllers();
}
But that's how i get it