Skip to content

Mage-messages cookie is not getting clear in specific store in magento setup

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.