从asp.net代码后面读表单认证cookie

前端之家收集整理的这篇文章主要介绍了从asp.net代码后面读表单认证cookie前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我们知道表单认证cookie是加密的。所以如何从我的代码后面读取表单认证cookie内容
if (Request.Cookies[".ASPXAUTH"] != null)
{
    HttpCookie myCookie = new HttpCookie(".ASPXAUTH");
}

解决方法

您可以使用FormsAuthentication提供的Decrypt方法访问故障单
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;
原文链接:https://www.f2er.com/aspnet/254029.html

猜你在找的asp.Net相关文章