Read form authentication cookie from asp.net code behind

后端 未结 1 1653
小蘑菇
小蘑菇 2020-12-13 04:06

We know that form authentication cookie is encrypted. so how to read the form authentication cookie content from my code behind.

if (Request.Cookies[\".ASPXA         


        
相关标签:
1条回答
  • 2020-12-13 04:55

    You can access the ticket with the Decrypt method provided by FormsAuthentication

    HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
    FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
    
    string cookiePath = ticket.CookiePath;
    DateTime expiration = ticket.Expiration;
    bool expired = ticket.Expired;
    bool isPersistent = ticket.IsPersistent;
    DateTime issueDate = ticket.IssueDate;
    string name = ticket.Name;
    string userData = ticket.UserData;
    int version = ticket.Version;
    
    0 讨论(0)
提交回复
热议问题