How to fix «Unable to send the cookie. Maximum number of cookies would be exceeded»

cookie

(Dmitry Fedyuk) #1

Magento 2 throws an exception if your browser session already have 20 cookies set and Magento need set some additional cookies:

Unable to send the cookie. Maximum number of cookies would be exceeded.

See the code:

I think this is the issue: Magento need handle the situation in some other way, not throwing an exception.
The issue is documented in Magento 2 issue tracker (#1500) and I expect it will be fixed to the Magento 2 Merchant Release date.

But now you need to clean some old cookies manually.
Here is an instructon for Google Chrome browser:

  1. Open Developer Panel by pressing F12 key
  • Select the Resources tab at the top of the Developer Panel.
  • Select the Cookies tab at the left of the Developer Panel.
  • Navigate to your store’s domain subitem of Cookies item:
  • Delete (by pressing DEL key) some cookies not related to Magento 2.
    At the picture below I clean WooCommerce cookies:


(Dmitry Fedyuk) #2

Looks like Magento 2 uses an obsoleted specification RFC 2109 for cookies limit.
The new specification is RFC 6265, and it allows at least 50 cookies per domain.

So the MAX_NUM_COOKIES limit can be safely increased up to 50.

Locate the line:

Replace it with the new one:

const MAX_NUM_COOKIES = 50;

See https://github.com/magento/magento2/issues/1500#issuecomment-156421883


(Dmitry Fedyuk) #3

See the cookie limits for the modern browsers.


(Dmitry Fedyuk) #4

It is fixed in the current release: https://github.com/magento/magento2/blob/2.0.0/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php#L29