Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 20-10-2008
Member
 
Join Date: Feb 2008
Posts: 137
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.
Reply With Quote
  #2  
Old 20-10-2008
Member
 
Join Date: Dec 2007
Posts: 1,592
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
Reply With Quote
  #3  
Old 20-10-2008
Member
 
Join Date: Mar 2008
Posts: 382
Hi,
you can also get the useful discussion through the following link for your question:
What Are The Cookies?

Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 06:13 AM.