---
title: "View state, Cookie and Session"  
description: "All these three are used to maintain state management. View and Cookie come under client state management technique and session come under server stat"  
author: "Manish Kumar"  
published: 2017-02-21  
updated: 2018-03-17  
canonical: https://www.mindstick.com/blog/11301/view-state-cookie-and-session  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# View state, Cookie and Session

All these three are used to maintain [state management](https://www.mindstick.com/blog/219/state-management-in-asp-dot-net). View and Cookie come under [client](https://www.mindstick.com/articles/12905/fynsis-announce-suitecrm-customer-portal-independent-client-service-platform) state management [technique](https://answers.mindstick.com/qa/93922/why-c-sharp-programmers-use-properties-technique-in-c-sharp-programming) and [session](https://www.mindstick.com/articles/12042/session-in-c-sharp) 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](https://www.mindstick.com/articles/1500/hashtable-and-dictionary-in-c-sharp) object for retaining value between [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) requests for the same page. It stores the value of the page and [controls](https://www.mindstick.com/articles/66/how-to-create-controls-at-run-time-in-csharp-dot-net) between round trips.

When we submit our page the [current state](https://www.mindstick.com/forum/158105/what-is-the-current-state-of-research-and-development-in-nanotechnology) of the page and all the controls is hashed into a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) and then saved it in the current page in the form of hidden fields. View store can store values.

\

![View state, Cookie and Session](https://www.mindstick.com/blogs/0d544c14-3cc3-4d8a-9ced-a906e56ba2fa/images/d63e07f5-9a27-4658-8c80-30480d3bd982.png)\

**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#**](https://www.mindstick.com/Articles/1293/cookies-in-asp-dot-net-c-sharp)

---

Original Source: https://www.mindstick.com/blog/11301/view-state-cookie-and-session

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
