I'm setting IsPersistent when signing the user in, how to read that value back?
var identity = await UserManager.CreateIdentityAsync(appUser, DefaultAuthenticationTypes.ApplicationCookie);
HttpContext.GetOwinContext().Authentication.SignIn(new AuthenticationProperties() { IsPersistent = false }, identity);
I asume DefaultAuthenticationTypes.ApplicationCookie contains cookie authentication scheme.
Since there isn't much description, I am not sure about the context. Anyway, you can get all the
AuthenticationProperties
that were provided with the sign in call when you perform authentication on the current request. Code would be..AspNet.Identity
gives you access to thebool
value ofIsPersistent
for the session. The most direct way to read its value is to callAuthenticateAsync()
:Note that you will need to wrap this in an
async
method, such as:AuthenticateResult authenticateResult = await HttpContext.GetOwinContext().Authentication.AuthenticateAsync(DefaultAuthenticationTypes.ApplicationCookie);
AuthenticationProperties yourAuthenticationProperties = authenticateResult.Properties;
can you please try this, I haven't test it
As @Nkosi said you can not retrieve the information from the OWIN, because it's not stored there, you need to retrieve the cookie itself and parse the information manually, but for that you will need a OWIN Middleware like this one so you can manipulate your cookie as you want.