blog

Home / DeveloperSection / Blogs / View state, Cookie and Session

View state, Cookie and Session

Manish Kumar3195 21-Feb-2017

All these three are used to maintain state management. View and Cookie come under client state management technique and session come under server state management technique.

View State- View state is a page level technique for state management. View state gives the facility of dictionary object for retaining value between multiple requests for the same page. It stores the value of the page and controls between round trips.

When we submit our page the current state of the page and all the controls is hashed into a string and then saved it in the current page in the form of hidden fields. View store can store values.


View state, Cookie and Session

Cookie- It is a small file that contains user information. It is used to store information about the user. It is stored in the local computer browser session. It contains site specific information that the server sends to the client it can be temporary with expiry date or persistent.                   

The purpose of a cookie is to store information about a particular client, session or application cookie is saved on the client device. We can access cookie information by requesting from the browser, client sends the information in the cookie along with the request information. 

Session-We know that web http is a stateless, protocol which means a new instance of a web page is re-created each time the page is posted to the server it can’t hold client information in a page. 

The Session is used to store information about client and it is also use for sending information of the current user. We can say that it is nothing more than a memory space in the form of a dictionary. It helps to maintain user data all over the application.

Saving and retrieving user information 

Session["key"] = "Mindstick";
string getkey;
getkey = Session["key"];

You can check this helpful related article

Cookies in asp.net c#


Updated 17-Mar-2018

Leave Comment

Comments

Liked By