.DottextCookie
442BE3E6843561B00F1EEE6E26B50666B172699F7BFCE2592DF181C235DEC2CFF90F1408A59692B7D8835F800C0F66802B599998FD3010D40A8CB3C810994C17612C22A5539D6D36
cnblogs.com/
9728
2469185920
29850605
2699157280
29844570
*
442BE3E6843561B00F1EEE6E26B50666B172699F7BFCE2592DF181C235DEC2CFF90F1408A59692B7D8835F800C0F66802B599998FD3010D40A8CB3C810994C17612C22A5539D6D36
cnblogs.com/
9728
2469185920
29850605
2699157280
29844570
*
我的方法是:
//
验证
ValidRight.LoginSys tmp = new ValidRight.LoginSys(strUserName, strPassWord);
if (tmp.Pass.ToString() == " True " )
{
string secretData = tmp.UserName + "," + tmp.ManaMK;
DateTime dt = DateTime.Now;
FormsAuthenticationTicket newTicket =new FormsAuthenticationTicket(1,"ticketNameWSF", dt,dt.AddMinutes(30), false, secretData);
HttpCookie newUserCookie = new HttpCookie("theCookieWSF");
newUserCookie.Value = FormsAuthentication.Encrypt(newTicket);
newUserCookie.Expires.AddMinutes(30);
Response.Cookies.Add(newUserCookie);
FormsAuthentication.RedirectFromLoginPage(tmp.UserID, false);
}
取值:
ValidRight.LoginSys tmp = new ValidRight.LoginSys(strUserName, strPassWord);
if (tmp.Pass.ToString() == " True " )
{
string secretData = tmp.UserName + "," + tmp.ManaMK;
DateTime dt = DateTime.Now;
FormsAuthenticationTicket newTicket =new FormsAuthenticationTicket(1,"ticketNameWSF", dt,dt.AddMinutes(30), false, secretData);
HttpCookie newUserCookie = new HttpCookie("theCookieWSF");
newUserCookie.Value = FormsAuthentication.Encrypt(newTicket);
newUserCookie.Expires.AddMinutes(30);
Response.Cookies.Add(newUserCookie);
FormsAuthentication.RedirectFromLoginPage(tmp.UserID, false);
}
HttpCookie userCookie
=
Request.Cookies[
"
theCookieWSF
"
];
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(userCookie.Value);
string [] SPsecretData = ticket.UserData.Split( new char [] { ',' } );
this .labUserName.Text = " 欢迎您, " + SPsecretData[ 0 ];
这样的话数据就会存储在Cookies目录下的index.dat文件内
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(userCookie.Value);
string [] SPsecretData = ticket.UserData.Split( new char [] { ',' } );
this .labUserName.Text = " 欢迎您, " + SPsecretData[ 0 ];