A cookie is a small text file sent to a web user's computer by a website. A cookie can be used to identify that user to the website on their next visit. Common uses include remembering login data, user preferences, and providing favorites lists.
Cookie specifications suggest that browsers should support a minimal number of cookies or amount of memory for storing them. In particular, an internet browser is expected to be able to store at least 300 cookies of four kilobytes each (both name and value count towards this 4 kilobyte limit), and at least 20 cookies per server or domain, so it is not a good idea to use a different cookie for each variable that has to be saved. It's better to save all needed data into one single cookie.
Setting cookies with a ASP.Net script is easy, we just need to use the HttpCookie class in the System.Web namespace. Let's look at an example on creating a cookie with ASP.Net
//Creating the cookie
HttpCookie sampleCookie = new HttpCookie("User");
sampleCookie.Expires = #01/01/2009#; // set the expiry
Response.Cookies.Add(sampleCookie); // Add it to the header
//Getting a cookie value
strUserName = Request.Cookies("User")("Name").ToString();
strUserCountry = Request.Cookies("User")("CountryCode").ToString();