Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what happens when cookies file exceeds maximum size?

What really happens when cookies file exceeds maximum size?

like image 374
Prady Avatar asked Oct 20 '09 16:10

Prady


People also ask

What is the maximum size of cookie in MB?

The 4K is the maximum size for the entire cookie, including name, value, expiry date etc. To support most browsers, it is suggested to keep the name under 4000 bytes, and the overall cookie size under 4093 bytes.

Can we increase cookie size?

In a modern browser you have better client-side storage alternatives. It is not a good idea to add an overhead of more than 4KB to every HTTP request. You can have a maximum of 50 cookies per domain and a total of 4KB. i.e. you can have 1 cookie of 4096 bytes, or 2 cookies with 2048, and so on.


2 Answers

The file is truncated to the maximum length.

like image 24
Deepakmahajan Avatar answered Sep 19 '22 17:09

Deepakmahajan


The typical behavior of most browsers, to my knowledge, is to simply truncate the oldest data that does not fit.

For example, create cookies 1 through 9. When creating cookie 10 and the data size is going to overflow, cookie 1 is simply discarded.

In general practice, if you are worried about bumping into the limit and loosing cookies to overflow, it is probably time to rethink your strategy of what you are storing and start caching the data server-side and limiting the cookie to a value to access the cached data.

like image 182
Mike Clark Avatar answered Sep 19 '22 17:09

Mike Clark