I create a FormsAuthentication ticket and store it in a cookie, which I use with MVC AuthorizeAttribute to provide authorization. Right now, I have this, so the cookie does not expire if I have the “stay in the game” checkbox selected (I just change the cookie.expires to date + 1 year, for testing purposes, you checked it to stay in the record) .
However, despite the fact that I have established that the cookie is permanent, when I create a ticket, the ticket still stops working after a timeout.
Here is the code where I create AuthTicket:
var now = DateTime.UtcNow.ToLocalTime(); FormsAuthenticationTicket authTicket = new System.Web.Security.FormsAuthenticationTicket(1, username, now, now.Add(FormsAuthentication.Timeout), rememberMe, username, FormsAuthentication.FormsCookiePath); string encryptedTicket = System.Web.Security.FormsAuthentication.Encrypt(authTicket); return encryptedTicket;
This is the same encrypted Ticket that I set as a cookie. Does anyone know how I can save this ticket until the FormsAuthentication timeout expires? Should I just vouch for the FormsAuthentication timeout?
source share