Application, Session, Cookies in ASP.NET

 

Application, Session and Cookies are used for state management in Asp.Net. 

Application Variables: 

You may wish to have certain variables from any page on your site, for any user, and at any time. These variables can be any Common Type System complaint data type, including a server-side object. You will use the Application object to store these variables for the life of the application. 

Session Variables: 

You may wish to have variables that are specific to a user for the life of their visit to your application. For this, you can use the Session object. You can initialize the Session variables in the Session_Start event handle in the Global.asax file. These variables can then be easily read and updated for each individual user. 

Cookies: 

Cookies enable you to store information on the user’s browser. A cookie can be either a single piece of information or an entire collection. After you store the cookie on the user’s browser, you can later access the cookie and the appropriate action. 

All these three variables are used to maintain the state. Application and Session variables stores the data in server side whereas cookies stores the data in client side(user browser).