magento2: Incorrect message: Unable to send the cookie. Maximum number of cookies would be exceeded

Previously this issue was reported in https://github.com/magento/magento2/issues/7931 and https://github.com/magento/magento2/issues/16568, but no one was able to reproduce it.

Preconditions

  1. Magento 2.2.5 installed via composer

Steps to reproduce

  1. Open desktop browser Firefox
  2. Navigate to about:config
  3. Find “dom.storage.enabled” option and change to “false”
  4. Navigate to Magento 2.2.5 (frontend), open developer tools >> Storage >> Cookies and look at list (there are 33 cookies) image
  5. Duplicate tab (open the same page in another page) - you will have 43 cookies. image
  6. Try to duplicate tab again - you will have 52 cookies. image

Expected result

  1. Cookies list should not grow such fast

Actual result

  1. We can take more then 50 cookies that leads to exception that described in https://github.com/magento/magento2/issues/7931 and https://github.com/magento/magento2/issues/16568

Tech note

I investigated issue described in https://github.com/magento/magento2/issues/16568 and found that we have 2 different polyfill implementaions for localStorage and sessionStorage:

  1. Added to page html (https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Theme/view/frontend/templates/js/polyfill.phtml)
  2. As part of jquery.storageapi library - https://github.com/magento/magento2/blob/2.2-develop/lib/web/jquery/jquery.storageapi.min.js

These implementation are fully different. 1st one works good, but 2nd one adds strange behavior - adds separate cookie with ls_ prefix in name for each item that should be stored in localstorage and ss_<some_id>_ for session storage. As result - when customer goes through website - it will add new and new cookies (because of this strange ss_<some_id>_ prefix).

Sometimess, we’re having 2nd implementation used instead of 1st one.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 6
  • Comments: 17 (10 by maintainers)

Most upvoted comments

Hi,

I investigated this issue more deeper. Previously magento was throwing an exception with message “Unable to send the cookie. Maximum number of cookies would be exceeded.”, but after https://github.com/magento/magento2/commit/369c963513775cccdd7d7b720d9c5ea5475653ff#diff-69abf748a729353f99cd623615fecd9dR210 - it’s just logging of such situation, but cookies are actually sending and no real issue there. This commit was included in Magento 2.2.0, also applied in 2.3.0

It seems like situation much less critical than I thought, just incorrect message is logged here.

So no need to change any constants, you can just ignore such messages, it will not affect production anyhow.

As I said above - it’s absolutely not critical issue, it could be ignored. What’s wrong there - message

On Wed, Aug 28, 2019 at 06:04 giangnv95 notifications@github.com wrote:

I got the same problem on magento 2.3.2, Is there any fix from Magento or contributors ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/magento/magento2/issues/17195?email_source=notifications&email_token=AAOJOUNDQG4PGAUIUWR3ZPDQGXTLTA5CNFSM4FMOBE32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5JXSUI#issuecomment-525564241, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOJOUM4QXHWGZ7TSYXSQHLQGXTLTANCNFSM4FMOBE3Q .

We are running into this on a customer’s website. Has anyone come up with a decent interim solution?