Results 1 to 3 of 3

Thread: Source code of cookies in ASP.Net and storage capacity.

  1. #1
    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.

  2. #2
    Join Date
    Dec 2007
    Posts
    1,599
    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

  3. #3
    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?


Similar Threads

  1. Replies: 10
    Last Post: 07-03-2012, 09:41 AM
  2. What is the Maximum storage capacity in Dell XPS 9000
    By Lotas in forum Hardware Peripherals
    Replies: 4
    Last Post: 21-04-2011, 12:13 PM
  3. hard disk showing high storage capacity
    By zulaik_mustaf in forum Hardware Peripherals
    Replies: 2
    Last Post: 20-08-2010, 11:33 AM
  4. How to check storage capacity of a SIM Card
    By Chetna Solanki in forum Portable Devices
    Replies: 5
    Last Post: 03-03-2010, 09:13 AM
  5. Infinite Storage Capacity for iPhones
    By MattyBoy in forum Portable Devices
    Replies: 2
    Last Post: 08-08-2008, 02:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,724,255.42510 seconds with 16 queries