Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

liandhas's avatar

Cookie length should be less than or equal to 4096 characters.

I have stored my cart data in Session, after I added 3 products into the cart, I get the following error.

Set-Cookie header is ignored in response from URL: Cookie length should be less than or equal to 4096 characters.

0 likes
3 replies
Sergiu17's avatar
Sergiu17
Best Answer
Level 60

You shouldn't store products in your 'Cookies', because it has limited memory, story only the ID of the product

franvillada's avatar

If you session driver is set to cookie, then all you store in session will be store as a cookie. You can change the session driver on the .env file and the config session.php file.

Also as @sergiu17 said you shouldn't store the whole product in you cookie only store the ID of the product and with that then you can access it later.

Regarding the error cookie length should be less than or equal to 4096 characters anyone know how can i fix that error? Im getting the same error. In my app im using cookie as the session driver and I store in the session only the name of a bussiness the user choose, but when i try to log in i get that error on console and then it redirect back.

Please or to participate in this conversation.