开发者

How many values can be stored in $_COOKIE[] on the client for a website?

Can I store as many a开发者_运维百科s values in setcookie? What's the limit?


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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜