16

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

Knut Hamang
  • 193
  • 1
  • 1
  • 7
  • 3
    possible duplicate of [What is the maximum size of a cookie, and how many can be stored in a browser for each web site?](http://stackoverflow.com/questions/2093793/what-is-the-maximum-size-of-a-cookie-and-how-many-can-be-stored-in-a-browser-fo) – Mahmoud Al-Qudsi May 13 '12 at 08:37
  • Just a comment on why I want to store data in the cookie; In my specific scenario, this would be an alternative to using ViewState( which is also sent back and forth during postback). However, when using updatepanels/AJAX, the browser refresh will not repost data, thus loosing the viewstate. Instead, the state could be saved in a cookie, and retried again for browser refresh. – Knut Hamang May 13 '12 at 10:39

3 Answers3

18

Here are the limits according to 'browser cookie limits':

Chrome & Firefox - No limit to the number of cookies; limit of 4096 bytes per cookie.

IE8-10 - 5117 characters per cookie; limit of 10234 characters.

Safari on Mac - 4093 bytes per cookie. Limit of 4093 bytes.

Safari Mobile - 4093 bytes per cookie. Limit of 4093 bytes.

Android - 4093 bytes per cookie. No limit.

I'd say if you have a destkop application, to be bound by the limits of IE or even Safari if you have Mac users. If it is on the phone, than definitely just 4093 bytes. If you need more, you are going to save to the server or create two different experiences for Safari / IE and Firefox / Chrome users.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Jonathan Tonge
  • 1,520
  • 19
  • 25
13

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.

gahooa
  • 131,293
  • 12
  • 98
  • 101
  • Thanks for the answer. I understand that the minimum of 4k is a standard. However the article I linked to also states that "In general, user agents' cookie support should have no fixed limits.". Does anyone know if there are any limits in the current browsers. – Knut Hamang May 13 '12 at 10:34
  • Is there no way to limit a cookie to one page? – jim smith Aug 01 '13 at 23:14
2

This can be also helpful here:

enter image description here

Amit kumar
  • 457
  • 6
  • 14