magento2: Unable to send the cookie. Size of 'mage-messages' is 13831 bytes in reports

Preconditions

  1. Magento CE 2.0.11

Steps to reproduce

  1. Login as customer
  2. Change email to an existing one of another customer
  3. Submit form

Expected result

  1. Should show an error message like ‘Email already in use’

Actual result

  1. On production server: 503 error

Unable to send the cookie. Size of ‘mage-messages’ is 13831 bytes.

This limit is set in Magento\Framework\Stdlib\Cookie\PhpCookieManager::MAX_COOKIE_SIZE 2. On developer mode: just page reload and no error message displayed for customer.

This error is caused by returned stack trace that is too large for the cookie limit (4096 bytes) in Magento\Customer\Controller\Account\EditPost::execute()

       try {
                $this->customerRepository->save($customerCandidateDataObject);
            } catch (AuthenticationException $e) {
                $this->messageManager->addError($e->getMessage());
            } catch (InputException $e) {
                $this->messageManager->addException($e, __('Invalid input'));
            } catch (\Exception $e) {
                $message = __('We can\'t save the customer.')
                    . $e->getMessage()
                    . '<pre>' . $e->getTraceAsString() . '</pre>';
                $this->messageManager->addException($e, $message);
            }

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 23 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@MTheProgrammer Magento CE 2.0.11 seriously? Update to latest version first than update or close this ticket. Creating tickets for an outdated version is very counterproductive.

@developer-lindner As I can see 2.0.11 is the latest version from 2.0 branch. If u think that 2.1 is newer version of 2.0 u’re in big mistake.

Same here, error is back in Magento 2.4.3-p1 …

same here in magento 2.4.3-p1

same here in magento 2.4.3-p2

This won’t be fixed. At least the size limit can’t be increased due to RFC specification, section 6.1 http://www.ietf.org/rfc/rfc6265.txt

One solution which I have in mind is to trim mage-messages and log its content when it overflows the limit of 4096b.

Try to log the message / log back trace… Then figure out which module is throwing this error.

It might be an observer on add to cart.

Sorry, issue on our site… Magento all good.

I am getting the same issue in 2.3.1, it is causing checkout to throw 503 error.

Closing as the fix for this issue is already available on Magento 2.1.0 and 2.2.0 branches.

Backports to 2.0.x are not processed due to its End of Life in November.