What is Cookie in ASP.NET?

An HTTP Cookie is a piece of data that is stored on the user's browser. Whenever you make a web-request, all the cookies associated with the domain are sent with the web- request.

On the server, we can access those cookies & read values from them. Hence, cookies help us in maintaining state by storing data on client's machine.

You can add a cookie in ASP.NET in following way:

 Response.Cookies.Add(new HttpCookie("Email", "[email protected]"));

To read the cookie, you can use below syntax:

string email = Convert.ToString(Request.Cookies["Email"]);
This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. For more information - please visit our private policy.