This article is a mirror article of machine translation, please click here to jump to the original article.

View: 15046|Reply: 0

[ASP.NET] asp.net Determining whether a user is logged in (SetAuthCookie related issues)

[Copy link]
Posted on 1/6/2016 6:41:19 PM | | |
If you use this method to write the user to a cookie after logging in, an authentication ticket is automatically created. FormsAuthentication.SetAuthCookie(tbUserName.Text, true);
How can you tell if a user is logged in?


FormsAuthentication.SetAuthCookie(tbUserName.Text, true);
If you want to get the logged-in username after using this method, use the following method:

Context.User.Identity.Name.ToString()

Principle: Because Form authentication is used, this is a current user of the system maintenance. If you use Form authentication, this is the logged-in person; If Win authentication is used, it is the user identity of the visitor logging in to the machine (similar to a domain user);



To implement the above functions, you must also add the following in your Web.config






Previous:Memcache looks at all key methods listed
Next:jQuery distinguishes elements with the same name?
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com