In general, the HTTP protocol is a stateless service, and it does not save any user request information. Web applications have been greatly developed until Netscape began using cookies to save user request information. Now asp.net programmers can save user request information in a number of ways.
Here are a few ways to ASP.net about client state management.
asp.net, which provides cookies, querystrings (URL), Hidden fields, View State and control state (ASP.net 2.0), manages client requests.
A, Cookie
Cookies are stored as text on your computer, using name-value matching. General user stores identify user information, such as user name, user Configuration, and so on. Although cookies can be stored encrypted, it is not recommended to save user passwords in cookies. Second, the size of the cookie is limited, so it is not appropriate to store large data.
Example:
1. Get User ID
if (request.cookies["UserId"]!= null)
Lbmessage.text = "Dear" + request.cookies["UserId"]. Value + ", Welcome to our website!";
else
Lbmessage.text = "Guest,welcome to our website!";
2. Set Cookies
response.cookies["UserId"]. Value=username;
Advantages:
Easy to use
Disadvantages:
1, the client can disable cookies
2, the cookie will be loaded every time the request or send, affect transmission.
3, easy to be breached, all not suitable for storing security information.