I have a project that uses Asp.net Identity (webApi). In the front end, I used Angularjs and I used sessionStorage to set and get token.
I'm trying to understand, can I use .AspNet.ApplicationCookie to authenticate a user without going back to the server?
Why expire time is showing N/A and what it is mean (See attached image)? and I want to test.AspNet.ApplicationCookie is expired?
I the following, I'm trying to set expired time and show user alert message when the session is expired:
In ApplicationOAuthProvider:
AuthenticationProperties properties = CreateProperties(user.UserName);
properties.AllowRefresh = true;
properties.ExpiresUtc = DateTime.UtcNow.AddMinutes(2);
properties.IsPersistent = true;
In Startup.Auth:
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationType =
DefaultAuthenticationTypes.ApplicationCookie,
ExpireTimeSpan = TimeSpan.FromMinutes(2),
SlidingExpiration = true,
AuthenticationMode = AuthenticationMode.Active
});
In Angularjs:
if (sessionStorage.getItem('accessToken') == null) {
alert("Your sesstion is expired !");
}
if (sessionStorage.expired) {
alert("Your sesstion is expired !");
};
None of these conditions is work!