What is the maximum size of a cookie, and how many can be stored in a browser for each web site?

9

4

I am learning about cookies, and I wonder about browser support:

  • For each domain/web site, how many cookies may be sent to a browser, and of what size?

  • If multiple cookies are sent and stored, does that affect performance?

user23982

Posted 2010-01-18T15:36:46.947

Reputation: 191

it's fine where it is; we now have two versions, one for SU (browser exe info) and one for SO (programmery info) http://stackoverflow.com/questions/2093793/what-is-the-maximum-size-of-a-cookie-and-how-many-can-be-stored-in-a-browser-for

– Jeff Atwood – 2010-01-19T16:57:17.823

Answers

10

Different browsers have different size limits on cookies. Some general guidelines:

Most of the documentation I've found (and there isn’t much) suggests that web browsers must support a minimum of:

  • 300 cookies in total
  • 20 cookies per domain
  • 4096 bytes per cookie

It seems as though this minimum requirement is part of the original RFC for cookies – see section 6.3 specifically.

A page that lists the actual in-practice cookie limits for several browsers:

Per Domain Cookie Limit

Here is a test script to test your browser:

  • Firefox 2: 501
  • Firefox 3: 501
  • Internet Explorer 72: 50 (after applying a patch from Microsoft)
  • Opera 9: 30
  • Safari: No Limit(!)

Maximum Cookie Limit:

  • Firefox 2: 10001
  • Firefox 3: 10001
  • Internet Explorer: unknown
  • Opera: unknown

1 can be set between 0 and 65535
2 documented by Microsoft here

Cookies are not saved on a server basis but on a domain basis (a server may host many domains or the opposite a server farm may be serving a single domain).

In general, I would avoid saving lots of information in cookies, as the data gets sent to and from the browser on every request. As you suggest in your question, this can have a effect on performance.

Usually one stores small amounts of data in the cookie, mostly used to identify the user/session so more data can be picked up from a database or another resource local to the web server.

Oded

Posted 2010-01-18T15:36:46.947

Reputation: 1 130

Here is a test page containing many of the latest browser limits. Some have moved on since this was written. – Iain – 2011-04-09T21:16:45.593

Cookies are quite unreliable as a state-preserving tool, because browser settings may block cookies from some or all domains. – harrymc – 2010-01-19T17:21:42.370

0

Based on my research I recommend you use no more than 50 cookies, and no more than 4093 bytes for all cookies per domain.

The lowest common denominator is:

  • IE 8/9/10/11 have a limit of 50 cookies, 5117 characters per cookie, and 10234 bytes per domain
  • Safari ?? on iPad iOS 5.1 have a limit of 600 cookies, 4093 bytes per cookie, and 4093 bytes per domain

Out of interest, notice that IE has a character limit while most have a byte limit. This means for multi-byte encodings like UTF-8 IE can fit in more data.

You can read more here: http://browsercookielimits.squawky.net/

Iain

Posted 2010-01-18T15:36:46.947

Reputation: 113