When using the current Asp.Net Identity handling code, it's possible to set a bunch of options in Startup.Auth to handle how the identification to handle how the cookie behaves.
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
SlidingExpiration = true,
ExpireTimeSpan = TimeSpan.FromMinutes(GetExpiryMinutesFromConfig()),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromSeconds(60),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
If a user is logged in, then this cookie will be deleted if they close the whole browser window. However, if they just close the tab, the cookie persists. I cannot find a CookieAuthenticationOptions
value that controls this.
I suspect deleting the cooked when a tab is closed may be difficult and undesirable from a UI point of view (what if there are multiple tabs open, for example). But is it actually possible.