My problem is valid only on the site I have published, Cookie works properly on localhost. However, after logging in to the site, it does not wait for the 1-day period it should wait.
public static void ConfigureCookie(this IServiceCollection services)
{
services.ConfigureApplicationCookie(options =>
{
options.LoginPath = "/Account/Login";
options.AccessDeniedPath = "/Account/AccessDenied";
options.Cookie = new()
{
Name = "ta_cookie",
HttpOnly = true,
SameSite = SameSiteMode.Lax,
SecurePolicy = CookieSecurePolicy.Always,
IsEssential = true
};
options.SlidingExpiration = true;
options.ExpireTimeSpan = TimeSpan.FromDays(1);
});
}
this is my code
var result = await _signInManager
.PasswordSignInAsync(user, model.LoginModel.Password,
model.LoginModel.RememberMe, true);
if (result.Succeeded)
{
return RedirectToAction("Index", "Home");
}
I want a session that will last 1 day to start, just like on localhost. Otherwise, cookies can be used, but as I said, it end early.
Could this be a cloudflare issue? Thanks for your answers.
I fixed that by adding this
builder.Services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromHours(12);
});
to Program.cs
It was related with ISS btw.