Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ihor-sviziev opened this issue Jul 27, 2018 · 17 comments
Labels
Component: Theme Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Severity: S4 Affects aesthetics, professional look and feel, “quality” or “usability”.

Comments

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Jul 27, 2018

Previously this issue was reported in #7931 and #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 Unable to send the cookie. Maximum number of cookies would be exceeded #7931 and local/session storage is mismanaged, particularly when it doesn't exist #16568

Tech note

I investigated issue described in #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.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jul 27, 2018
@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Jul 27, 2018

Hi @ihor-sviziev. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me {$VERSION} instance

where {$VERSION} is version tags (starting from 2.2.0+) or develop branches (2.2-develop +).
For more details, please, review the Magento Contributor Assistant documentation.

@ihor-sviziev do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@ghost ghost self-assigned this Jul 27, 2018
@ghost ghost added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Component: Theme labels Jul 27, 2018
@ghost
Copy link

ghost commented Jul 27, 2018

@ihor-sviziev, thank you for your report.
We've acknowledged the issue and added to our backlog.

@convenient
Copy link
Contributor

If a customer ends up with 50 or more cookies for whatever reason then they're basically locked out until they clear their browser cookies correct?

If the above is correct then I'm toying with the idea whether it would it be sensible to automatically wipe all the customers cookies when this error occurs and the exception is thrown

  • Either way the customer won't get browsing until they clear their cookies
  • Doing so automatically will annoy the customer by logging them out, but not so bad as never being able to reliably browse the site again.
  • Even in this day and age many customers do not know how to clear their cookies, so this lowers the barrier of recovery and makes these errors a little less catastrophic.
  • I believe the 2.2 series has improved new relic logging of reports so this would still be caught and tracked, easily identified when instances of "i was randomly logged out" are reported.

Obviously we should focus on fixing the core magento bug, but I've just seen this error caused by some rogue GTM code creating cookies in a loop and was wondering on how to make this error a little less cataclysmic.

Just a thought ¯\(ツ)

@ihor-sviziev
Copy link
Contributor Author

Hi @convenient,
I investigated this issue deeper and found that in 1598c0f#diff-69abf748a729353f99cd623615fecd9dR206 throwing an exception was changed to logging, but message was not updated. Magento CAN set more than 50 cookies, but just writing quite big list of messages "Unable to send the cookie. Maximum number of cookies would be exceeded" in logs, that is confusing people.

I think proper fix will be just updating logged message

@convenient
Copy link
Contributor

Interesting. Should magento be allowing that many cookies to be set? It's getting very close to the max limit for some browsers which could result in undefined behaviour.

cookie-support-browsers

@ihor-sviziev
Copy link
Contributor Author

@convenient i checked, m1 websites works good even with 80+ cookies in IE and another browsers, so it's not a big deal

@JosephMaxwell
Copy link
Contributor

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

@adamj88
Copy link

adamj88 commented Dec 6, 2018

@ihor-sviziev
Copy link
Contributor Author

ihor-sviziev commented Dec 7, 2018

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 369c963#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.

@giangnv95
Copy link

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

@ihor-sviziev
Copy link
Contributor Author

ihor-sviziev commented Aug 28, 2019 via email

@giangnv95
Copy link

giangnv95 commented Aug 28, 2019

@ihor-sviziev Thanks for reply, cause it's just a warning mess, I also think I can ignore it :)
I just asking again to make sure I don't miss anything valuable 👍

@ihor-sviziev ihor-sviziev changed the title Unable to send the cookie. Maximum number of cookies would be exceeded Incorrect message: Unable to send the cookie. Maximum number of cookies would be exceeded Oct 17, 2019
@ahmadalkaid
Copy link

Dears,
The issue still there, even when we are in the production mode. I had to override the file to fix it. I am using:
Magento 2.3
PHP 7.1.33

So could anyone help here?

Thanks,

  • Kaid

@FerihumF
Copy link

Same issue on 2.2.7.

@n2diving-dgx
Copy link

Same issue on 2.3.4

@ihor-sviziev
Copy link
Contributor Author

Seems like this issue should reproduce much less as it not creating cookies for translations anymore.
Related changes:
on frontend 71c781d
on backend #27364.

@ihor-sviziev ihor-sviziev added the Severity: S4 Affects aesthetics, professional look and feel, “quality” or “usability”. label Jul 29, 2020
@slavvka
Copy link
Member

slavvka commented Aug 8, 2020

Hi @ihor-sviziev. Thank you for your report.
The issue has been fixed in #27364 by @ihor-sviziev in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.1 release.

@slavvka slavvka added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Aug 8, 2020
@slavvka slavvka closed this as completed Aug 8, 2020
@ghost ghost moved this from Ready for Dev to Done (last 30 days) in Community Backlog Aug 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Theme Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Severity: S4 Affects aesthetics, professional look and feel, “quality” or “usability”.
Projects
No open projects
Community Backlog
  
Done (last 30 days)
Development

No branches or pull requests