1

I am facing a strange issue with cookies in the Magento store.

The problem is that the "mage-messages" cookie is not being cleared in the US store. In Magento, we have a setting as shown in the attached image, and there's a line of code which clears the cookie

$.mage.cookies.set('mage-messages', '', {
    samesite: 'strict',
    domain: '',
    path: '/'
});

Interestingly, when I modify the path to /us/ in the above code, it starts working:

$.mage.cookies.set('mage-messages', '', {
    samesite: 'strict',
    domain: '',
    path: '/us/'
});

Here are the console values I receive:

Current URL: http://wholesale.abc.local/us/customer/account/create
Current Path: /us/customer/account/create
Current Domain: wholesale.abc.local

Does anyone have insights regarding the cookie domain? I'm finding the cookie domain concept a bit unclear with multi-website stores in Magento.

1 Answer 1

0

Multi website does create a lot of issues in Magento especially if you multiple domain paths as usually as you've mentioned Magento doesn't specify cookie domain and cookie path while setting or clearing cookies.

If you want the cookies to be more reliable you can get the current domain and domain path by injecting Magento\Framework\Session\Config\ConfigInterface and calling getCookieDomain() and getCookiePath() respectively.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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