开发者

Retrieve Forms Authentication Expiration Date/Time

I'm using forms authentication and currently create a forms auth ticket when a user logs in, and set an expiry of about 5 days if they have requested to persist the login.

I now need to create an additional cookie to store some additional settings and IF a user is authenticated, I would like to be able to get the date/time that their forms auth ticket is due to expire, whether the forms ticket is persistent, and set that as the expiry for my other cookie, but I don't k开发者_如何学Pythonnow how to get that forms auth expiration date/time or check if it's persistent.

Can this information be extracted from the encrypted forms auth ticket?


Use the FormsAuthenticationTicket.

FormsIdentity identity = HttpContext.Current.User.Identity as FormsIdentity;
FormsAuthenticationTicket ticket = identity.Ticket;
//ticket.Expiration
//ticket.IsPersistent

Plus you can get the cookie like:

HttpCookie cookie = Request.Cookies[FormsAuthentication.FormsCookieName];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜