Asp. NET application, session and cookie differences

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.