Home > Net >  How to rely on the created user login id Cookie validation judge the state of the user login?
How to rely on the created user login id Cookie validation judge the state of the user login?

Time:01-03

Login to have passed the daemon create user login identity of cookies, again how open the web page based on user login identity validated Cookie judge the state of the user login?

 
//get the user role
String userdata=https://bbs.csdn.net/topics/txtID.Value;

//create the authentication ticket
FormsAuthenticationTicket authTicket=new FormsAuthenticationTicket (1, txtID. Value, DateTime. Now, a DateTime. Now the AddMinutes (360), the true, the userdata);

String encryptedTicket=FormsAuthentication. Encrypt (authTicket);

//create a Cookie
HttpCookie authCookie=new HttpCookie (FormsAuthentication FormsCookieName, encryptedTicket);

The Response. Cookies. Remove (" authCookie ");

The Response. Cookies. The Add (authCookie);

CodePudding user response:

Determine whether the login
User. Identity. IsAuthenticated
To obtain the userdata you
User. Identity. Name

CodePudding user response:

Still don't understand, can write more specifically? How to get the local Cookies to judge whether the login?
  • Related