SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict Volitics's Avatar
    Join Date
    Aug 2003
    Location
    US
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How much data, or how long a string, will a cookie hold?

    Hello;

    I am working on a web site that is going to need a cookie to hold a string of information.

    I have got a few questions about storing data in a cookie:


    1). How long a string of data, or how many characters, will a cookie hold?


    Also, I am thinking about storing the data in a session cookie.

    2-a). How much data will will a session cookie variable hold?

    2-b). How much data will the entire session cookie hold?

    Does anybody know where I can find answers to my questions?

    Thanks.
    .

  2. #2
    SitePoint Guru aamonkey's Avatar
    Join Date
    Sep 2004
    Location
    kansas
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure what the limit is on cookies - sessions afaik don't necessarily have a limit.

    However, remember the rule of upper limits: if you have to ask what the upper limit is, you're probably doing it wrong.

    Not sure what you're trying to do exactly, but you shouldn't need to store a ton of information in either. Just store an identifying key in the session, and use that to pull the information you need from the database.
    aaron-fisher.com - PHP articles and more

  3. #3
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Volitics View Post
    Does anybody know where I can find answers to my questions?
    Yep.

    RFC 2965 - HTTP State Management Mechanism (RFC2965)
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  4. #4
    SitePoint Addict Volitics's Avatar
    Join Date
    Aug 2003
    Location
    US
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    aamonkey, AnthonySterling;

    Thanks for responding to my question.

    For others who read this thread the link to the white paper provided by Anthony tells about storage requirements for cookies. It's about 3/4 down the page under the subheading "5.3 Implementation Limits"

    It says there "In general, user agents' cookie support should have no fixed limits." (I think the term user agents refers to browsers)

    I think that a cookie is like any other text file. I suppose that you can put lots of information in one. The limitation is only how much data your computer can handle. Most computers can handle huge text files.

    It also says that the user agent (i.e. browser) should have the capacity to contain at least 4096 bytes of data in a cookie (if I am reading it right).

    One byte of data equals one keyboard character.

    Thanks again.
    .


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
  •