tags:

views:

159

answers:

3

Can I store as many as values in setcookie? What's the limit?

A: 

As far as i know, you can store about 4kb. Thus, you can use setcookie to store about that much stuff.

http://support.microsoft.com/kb/306070

Sarfraz
The article only applies to IE up to 5.5
Sebastian Sedlak
+2  A: 

I think, the maximum size of a cookie depends on the browser.

See RFC 2965

5.1 Implementation Limits

  • at least 300 cookies
  • at least 4096 bytes per cookie (as measured by the characters that comprise the cookie non-terminal in the syntax description of the Set-Cookie2 header, and as received in the Set-Cookie2 header)
  • at least 20 cookies per unique host or domain name

/edit: Another interesting Post

  • IE7/8 is 50 Cookies per Domain and 4095 Characters for name, value and equal sign
  • Firefox 50 Cookies and 4097 Characters
  • Opera 50 Cookies and 4096 Characters
  • Safari/WebKit unlimited Cookies and 4097 Characters
Sebastian Sedlak
A: 

Something different, whenever you ask this kind of question, there's probably a design problem. Better make use of the server-supplied session object or store some unique identifier in the cookie which you associate with the data which is stored server-side in some sort of database. This way you end up with only one cookie with "unlimited" information.

BalusC