How To Read And Write A Cookie In ASP.NET

You can use cookies to store data about your site visitors. Because cookies are just plain text files, they are usually not used to store sensitive data, especially without some kind of encryption.

To create new cookie or save existing cookie, use this code:

[ C# ]

Response.Cookies["CookieName"].Value =
"CookieValue";// Cookies are temporally files, so you need to set how long cookie will be present on client hard disk before it is deleted
Response.Cookies["CookieName"].Expires = DateTime.Now.AddDays(100);

[ VB.NET ]

Response.Cookies("CookieName").Value =
"CookieValue"' Cookies are temporally files, so you need to set how long cookie will be present on client hard disk before it is deleted
Response.Cookies("CookieName").Expires =
Now.AddDays(100)