How to check "createPersistentCookie" in ASP.NET Forms Authentication?

When someone logs into my application and they checked the Remember Me checkbox, I set createPersistentCookie = trueit so that when they return, they don’t need to log in again. However, sometimes, I need to use it FormsAuthentication.SetAuthCookie(NewUserName, [true/false]), since I know if they initially set the value createPersistentCookieto true or not, so can I keep it the same as when I logged in?

+1
source share
2 answers

I believe that when decrypting the cookie you should leave FormsAuthenticationTicket, after which you can request a property IsPersistent.

To decrypt:

FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value);

References: FormsAuthentication.Decrypt () on MSDN

+2

All Articles