I recently deployed my asp.net core mvc web app (.NET 4.6.1) to a shared hosting server. The following is what I used to set the session cookie parameters:
services.AddIdentity<ApplicationUser, IdentityRole>(config =>
{
config.Cookies.ApplicationCookie.LoginPath = "/login";
config.Cookies.ApplicationCookie.CookieName = "MyCookie";
config.Cookies.ApplicationCookie.ExpireTimeSpan = TimeSpan.FromHours(1.0);
config.Cookies.ApplicationCookie.SlidingExpiration = true;
}
However, I notice that:
1) When opening chrome developer tools, the 'Expires/Max Age' column shows "Session" for my auth cookie compared to the actual timeout value (which I set to be 1 hour).
2) After a few minutes, I get logged off on my hosted website automatically (even though session is set to expire for 1 hour). - This problem still exists
Can you please let me know what I am doing wrong, or if I am missing anything?
EDIT:
I also have another session but that's just used to keep lightweight data about the client.
services.AddMemoryCache();
services.AddSession(options => {
options.CookieName = "myOtherCookie";
options.IdleTimeout = TimeSpan.FromDays(1.0);
});
My sign-in code:
var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, true, lockoutOnFailure: true);
Snippet of my Configure Method:
app.UseStaticFiles();
app.UseIdentity();
app.UseSession();
app.UseMvc(
routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
}
);
Many thanks
Terry