In ASP. Application, sessions, and cookies can hold information, so what's the difference?
First, First application is to establish a state variable on the server side, stored in the server's global variables to store the required information. It is built in memory, and this variable can be accessed by all pages of the site.
To access the Application object variable method:
application["variable name"]= variable value variable =application["variable name"]
Example: can be used in the site to count the number of users access to facilitate the administrator of the site access statistics.
Second, the session is used to store the user's information on the server side, each session for a window, with SessionID identification, this session for the window and its child window sharing. is cleared when the user ends the session.
Two implementations: 1) Use of cookies (when cookies are available)
2) URL rewrite (when coolie is disabled)
Example: The site has different permissions of users, landing after the entry of the page is also different, can be logged into the user class session, according to different categories of landing to achieve different navigation functions.
Third, the cookie is stored in the client, allowing the Web server to store a small amount of data on the client hard disk or in memory, or read from the client hard disk. It can record the user's ID, password, visited pages, dwell time and so on.
Example: Use cookies to store information about a user's landing site. After the first landing, the login information is written to the cookie of the user's computer, and it is not required to be filled in directly when landing again.
Just started to know that these three can store some information, but bright vaguely, specifically do not know God horse use. After comparison, we don't have to worry about the use of them. The teacher said the comparison is the best study, this is the truth!
ASP. NET application, session, and cookie differences