10

Every time I open var/Repots in magento 2 website, I found hundreds and thousands of error files all having the same message:

a:4:{i:0;s:71:"Unable to send the cookie. Maximum number of cookies would be exceeded.";
i:1;s:12555:"#0 /home/domain/public_html/vendor/magento/framework/Stdlib/Cookie/PhpCookieManager.php(116): Magento\Framework\Stdlib\Cookie\PhpCookieManager->checkAbilityToSendCookie('form_key', '........')...

I searched a lot, but I did not find a solution. The maximum number of cookies is set to 50 by default.

The problem is not happening on my browser. It mostly happens with customers using android mobile phone's browser Android Version 4.0.2 to 4.4.0.

Clearing cache or using private browsing solves the issue on the client side. However I need a server side solution. (I asked a customer to clear the cache and the problem is solved on his mobile).

8
  • How many cookies are set? Are all of them necessary? – Pharaoh Sep 18 '17 at 10:49
  • actually I don't know. It is created automatically by the magento framework. – Moe Hammadi Sep 18 '17 at 10:52
  • It is not happening in my browser. It mostly happens with customers using android 4.0.2 to 4.4.0 mobile browsers. – Moe Hammadi Sep 18 '17 at 10:54
  • I updated my question – Moe Hammadi Sep 18 '17 at 11:00
  • which magento version are you using? – CompactCode Sep 19 '17 at 12:35
1

This article should help give you a better idea on the Root Cause (i.e. how/what/why) of the issue - https://mage2.pro/t/topic/84/2

Unfortunately, it doesn't look like Magento is in any hurry to fix the issue for Android OS based browsers - https://github.com/magento/magento2/issues/7931

7
0

I Was able to solved this problem by increase const MAX_COOKIE_SIZE = 40960;

public_html/vendor/magento/framework/Stdlib/Cookie/PhpCookieManager.php

const MAX_NUM_COOKIES = 50;
const MAX_COOKIE_SIZE = 40960;
const EXPIRE_NOW_TIME = 1;
const EXPIRE_AT_END_OF_SESSION_TIME = 0;
0

Extend in di.xml

<preference for="Magento\Framework\Stdlib\Cookie\PhpCookieManager" type="Project\Cookies\PhpCookieManager" />
namespace Project\Cookies;

class PhpCookieManager extends \Magento\Framework\Stdlib\Cookie\PhpCookieManager
{

    const MAX_NUM_COOKIES = 666;
    const MAX_COOKIE_SIZE = 40960;
    const EXPIRE_NOW_TIME = 10;
    const EXPIRE_AT_END_OF_SESSION_TIME = 50;
    
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.