11

I know that there is a limit on how much data can a cookie hold, but is there a limit on how many cookies can we set?

daniels
  • 18,416
  • 31
  • 103
  • 173

3 Answers3

10

Based on my own research, I suggest that you do not exceed 50 cookies per domain, and 4095 bytes per domain. That is, the size of all the cookies on your domain should not exceed 4095 bytes.

If you want to read more, I have shared my research here.

Iain
  • 10,814
  • 3
  • 36
  • 31
8

From http://www.ietf.org/rfc/rfc2109.txt

Practical user agent implementations have limits on the number and size of cookies that they can store. In general, user agents' cookie support should have no fixed limits. They should strive to store as many frequently-used cookies as possible. Furthermore, general-use user agents should provide each of the following minimum capabilities individually, although not necessarily simultaneously:

  * at least 300 cookies

  * 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)

  * at least 20 cookies per unique host or domain name
arnehehe
  • 1,386
  • 1
  • 17
  • 33
0

I've seen websites in the wild that were setting over 450 cookies and reporting to over 140 distinctive third party domains.

kravietz
  • 10,667
  • 2
  • 35
  • 27