Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much data can I store in a cookie

Are there any limits in modern browsers regarding how much data I can store in one single cookie?

I found an article stating it should hold a minimum of 4k, but no upper limit. http://www.faqs.org/rfcs/rfc2965.html

like image 509
Knut Hamang Avatar asked May 13 '12 08:05

Knut Hamang


People also ask

Can you store data in cookies?

This allows you to stay logged in to a website and allows the site to present you with information customized to fit your needs. Cookies can store a wide range of information, including personally identifiable information (such as your name, home address, email address, or telephone number).

Do cookies have a size limit?

While it may appear to be a strange joke, browsers do impose cookie limits. A browser should be able to accept at least 300 cookies with a maximum size of 4096 bytes, as stipulated by RFC 2109 (#6.3), RFC 2965 (#5.3), and RFC 6265. (including all parameters, so not just the value itself).

How much cookie data is too much?

To be compatible with the widest range of browsers, create no more than 30 cookies per domain and make sure all 30 cookies take up no more than 4KB of space in total. Kyrnin, Jennifer. "How Many Cookies Can You Use on One Website?" ThoughtCo, Jul. 31, 2021, thoughtco.com/cookie-limit-per-domain-3466809.


1 Answers

To comply with the standard, you should store no more than 4096 bytes per cookie.

Another point worth remembering is that cookies are sent on EVERY request to the matching domain, which is very significant overhead in the case of a sizable cookie (upload speeds are often 10x slower than download speeds).

As to specific limits per browser, I defer to another response.

like image 185
gahooa Avatar answered Nov 20 '22 17:11

gahooa