I've been doing some research into cookies for my upcoming book and came across some interesting facts about the way browsers handle cookies. I started out by looking at the number of cookies that browsers allowed per domain. The results were interesting:
Cookie header. The problem is that the header size exceeded the limit that the server could process, so an error occurred.So the prevailing knowledge that browsers limit per-domain cookies to 20 is no longer valid. Another interesting inconsistency is how browsers react when too many cookies are set. With the exception of Safari, which sets all cookies regardless of the number, there are two approaches:
The total size of cookies also varies from browser to browser. This is another one that is a little hard to comprehend, but here's what my tests show:
It's worth noting that single-byte characters were used for these tests; multi-byte characters will, naturally, count as two. In all browsers, any cookie that is set with a size greater than the limit is ignored and never set.
My conclusion after doing all of these tests is that the traditional beliefs of cookie limitations (mostly taken from the original cookie specification) are no longer valid. We should use caution when using cookies and always take the lowest limit as the one to look out for.
Nicholas,
One question. When you are talking about characters' limit (4096 for example), do you mean characters or bytes? Have you tried non-ASCII Unicode characters? I mean otherwise we should say 4096 bytes, not characters.
Also, have you seen this post? http://blogs.msdn.com/ie/archive/2007/08/29/update-to-internet-explorer-s-cookie-jar.aspx
It proves that the increase in number of cookies per domain occurred before IE8.
@Alexei - Technically, the limit is specified in bytes, but practically everyone thinks of them as characters. This is why I mentioned that double-byte characters count as two. :)
Thanks for the link, I hadn't noticed that. Glad to know I'm not going crazy (just yet).
Nicholas,
Sorry, somehow I missed the paragraph where you answered my question :). My fault.
Post Comment
Your e-mail address will never be shown, only your URL. Please, no HTML in your comments, as it will be automatically stripped out for security purposes.