Learn the Maximum Size That a Web Cookie Can Be

Close-Up Of Chocolate Chip Cookie On Laptop
Rara Subair / EyeEm / Getty Images

A web cookie (often just called a "cookie") is a small piece of data that a website stores in a user's web browser. When a person loads a website, the cookie can tell the browser information about their visit or previous visits. This information can allow the site to remember preferences that may have been set during a previous visit or it can recall activity from one of those previous visits.

Have you ever been to an E-commerce website and added something to the shopping cart, but failed to complete the transaction? If you returned to that site at a later date, only to find your items waiting for you in that cart, then you have seen a cookie in action.

The Size of a Cookie

The size of an HTTP cookie (which is the actual name of web cookies) is determined by the user agent. When you measure the size of your cookie, you should count the bytes in the entire


pair, including the equal-sign.

According to the RFC 2109, web cookies should not be limited by user agents, but the minimum capabilities of a browser or user agent should be at least 4096 bytes per cookie. This limit is applied to the


portion of the cookie only.

What this means is that if you're writing a cookie and the cookie is less than 4096 bytes, then it will be supported by every browser and user agent that conforms to the RFC.

Remember that this is the minimum requirement according to the RFC. Some browsers may support longer cookies, but to be safe, you should keep your cookies under 4093 bytes. Many articles (including a previous version of this one) has suggested that staying under 4095 bytes should be sufficient to ensure full browser support, but some tests have shown that certain newer devices, like the iPad 3, come in a little lower than 4095.

Testing for Yourself

A great way to determine the size limit of web cookies in different browsers is to use the Browser Cookie Limits test

Running this test in a few browsers, we got the following information for the latest versions of these browsers:

  • Google Chrome - 4096 bytes
  • Internet Explorer - 5117 bytes
  • Firefox - 4097 bytes
mla apa chicago
Your Citation
Kyrnin, Jennifer. "Learn the Maximum Size That a Web Cookie Can Be." ThoughtCo, May. 14, 2021, thoughtco.com/cookie-size-limit-3466810. Kyrnin, Jennifer. (2021, May 14). Learn the Maximum Size That a Web Cookie Can Be. Retrieved from https://www.thoughtco.com/cookie-size-limit-3466810 Kyrnin, Jennifer. "Learn the Maximum Size That a Web Cookie Can Be." ThoughtCo. https://www.thoughtco.com/cookie-size-limit-3466810 (accessed January 30, 2023).