Cookie Limits Test

stolen from http://myownplayground.atspace.com/cookietest.html

I have a requirement to store a large amount of data in cookies, to figure out if it will work here are my tests.

If all you care about is the conclusion, well here it is: If you want to support most browsers, then don't exceed 50 cookies per domain, and don't exceed 4095 bytes per domain (i.e. total size of all cookies <= 4095 bytes)

Current Browser Test Results

About The Tests

Max Cookie Count Per Domain is calculated by adding cookies until the number of cookies saved stops increasing.

Max Cookie Size Per Cookie is calculated by increasing the cookies value one character at a time, until the saved value is truncated.

Max Cookie Size Per Domain is guessed by adding cookies of maximum size, until no more cookies can be added. Hence, the actual limit may be more than the guessed limit. Guessed Limit <= Actual Limit < Guessed Limit + Max CookieSize

Manually Execute Tests

1. Max Cookies Test

Each cookie will be filled with the following character, repeated the specified number of times.
Character: Repeat Character Times:

Some Interesting Things

Typically, the following are allowed: * Given 20 cookies of max size 4096 = 81920 bytes.

IE (and Opera) introduces a new limit, max bytes per domain

A few notes about cookies:

Alternatives

Browser Limits

After testing a few browsers myself, and using Browser Shots I have compiled the following list:
Browser Max Cookies Max Size Per Cookie Max Size Per Domain1 Usage2
Chrome 4
Chrome 5704096 bytesNA
Chrome 6704096 bytesNA
Chrome 7704096 bytesNA
Chrome 81804096 bytesNA0.6%
Chrome 97.7%
Chrome 101804096 bytesNA14.8%
Chrome 110.8%
Chrome 120.1%
FireFox 2504097 charactersNA
FireFox 3504097 charactersNA36.7%
FireFox 4504098 charactersNA5.2%
IE 6504096 characters4096 characters3.0%
IE 7504095 characters4095 characters5.4%
IE 8505117 characters10234 characters16.3%
IE 91.1%
Opera 8304096 bytes4096 bytes
Opera 9304096 bytes4096 bytes
Opera 100.2%
Opera 11604096 bytes4096 bytes1.9%
Safari 30.1%
Safari 40.3%
Safari 56004096 bytes4096 bytes3.6%
Safari on mac3???
1 NA means there is no limit other than Max Cookies * Max Size Per Cookie
2 From March 2011 W3 Schools Browser Statistics
3 Lu pointed out Safari on mac is different to windows. It appears to have no limit. I will investigate when I get more time.

Conclusion

If you want to support most browsers, then don't exceed 50 cookies per domain, and don't exceed 4095 bytes per domain (i.e. total size of all cookies <= 4095 bytes)

Updates