hi programming Gurus,
Can anyone explains me the source code of cookies in ASP.Net and how much cookies are allowed to store in an Internet Browser.
Thanks in Advance.
hi programming Gurus,
Can anyone explains me the source code of cookies in ASP.Net and how much cookies are allowed to store in an Internet Browser.
Thanks in Advance.
Hi wllwnn,
Setting cookies with a ASP.Net script is easy, we just need to use the HttpCookie class in the System.Web namespace. Following is an example of creating a cookie with ASP.Net
Code in C#
//Creating the cookie
HttpCookie sampleCookie = new HttpCookie("User");
sampleCookie.Values.Add("Name", strUserName);
sampleCookie.Values.Add("CountryCode", strCountry);
sampleCookie.Expires = #01/01/2009#; // set the expiry
Response.Cookies.Add(sampleCookie); // Add it to the header
//Getting a cookie value
String sGetCookie;
strUserName = Request.Cookies("User")("Name").ToString();
strUserCountry = Request.Cookies("User")("CountryCode").ToString();
According to me, 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.
cheers
Hi,
you can also get the useful discussion through the following link for your question:
What Are The Cookies?
Bookmarks