Google搜索告诉我,最大允许的Cookie数量取决于浏览器,但是我无法找到任何有关在现代浏览器上允许多少Cookie的数据。
As far as Google searches tell me, the maximum allowed number of cookies depends very much on the browser, however I cannot find any recent data as to how much cookies are allowed on modern browsers.
我需要在Cookie中存储一些大量的用户偏好(对于尚未注册的用户),那么最好的办法是什么呢? (另外,这些Cookie将通过javascript客户端和php服务器端访问)
I need to store a somewhat large number of user preferences in cookies (for not-yet-registered users), so what would be the best way of doing that? (Also, those cookies would be accessed both via javascript client-side and php server-side)
推荐答案从 rfc :
-
至少300个Cookie
at least 300 cookies
每个Cookie至少有4096个字节(由组成字符的大小衡量) cookie非终端的语法 Set-Cookie头的描述)
at least 4096 bytes per cookie (as measured by the size of the characters that comprise the cookie non-terminal in the syntax description of the Set-Cookie header)
每个唯一主机或域名至少20个Cookie
at least 20 cookies per unique host or domain name
这些是最低要求。 IE6团队没有得到。一切都是高度浏览器特定的。你最好写一个测试平台来测试每个浏览器。
Those are minimum requirements. The IE6 team didn't get that. Everything else is highly browser-specific. You'd better write a test-platform to test each browser. Test the maximum size and number with little incremental steps (and check if they still are readable).
此外,我似乎记得apache有一个问题与huges数量的cookie 。
Also, I seem to remember apache has a problem with huges numbers of cookies. Can't remember where i've seen that though.
这里是一个小小的测试脚本: krijnhoetmer.nl/stuff/javascript/maximum-cookies/
Here is a little cookie-testing script: krijnhoetmer.nl/stuff/javascript/maximum-cookies/
更多推荐
允许的最大Cookie数
发布评论