Source code of cookies in ASP.Net and storage capacity.
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.
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.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();
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.
|Tags: aspnet source code, cookies|
|Thread Tools||Search this Thread|
|Similar Threads for: "Source code of cookies in ASP.Net and storage capacity."|
|Thread||Thread Starter||Forum||Replies||Last Post|
|Internet explorer 9 displays Cookies error message? IE9 works better when it is cookies enabled, please enable cookies?||Bellare||Technology & Internet||10||07-03-2012 09:41 AM|
|What is the Maximum storage capacity in Dell XPS 9000||Lotas||Hardware Peripherals||4||21-04-2011 12:13 PM|
|hard disk showing high storage capacity||zulaik_mustaf||Hardware Peripherals||2||20-08-2010 11:33 AM|
|How to check storage capacity of a SIM Card||Chetna Solanki||Portable Devices||5||03-03-2010 09:13 AM|
|Infinite Storage Capacity for iPhones||MattyBoy||Portable Devices||2||08-08-2008 02:06 PM|