Hello,
I'm using cookies in Magento 2 to handle a modal to display a store selector. I'm using multiples subdomains for each website handling store views.
In administration I did set cookie domain to ".my-domain.com", cookie path is "/"
My script looks like :
<script>
require([
'jquery',
'mage/cookies',
'Magento_Ui/js/modal/modal',
'domReady!'
],function($){
var cookie = $.mage.cookies['defaults']['lifetime'];
if(!$.mage.cookies.get("storeselectorpopup")){
$.mage.cookies.set('storeselectorpopup', 'true');
$('.popup-storeselector').modal({
autoOpen: true,
wrapperClass: 'modals-wrapper popup-storeselector',
responsive: true,
});
}
});
</script>
The problem is that user is asked twice when the subdomain changes, for example, landing page is www.my-domain.com, if the user selects Europe, he gets redirected to europe.my-domain.com, so the modal appears again.
I also tried to set cookie domain empty.
Any idea on what I missed here please ?
Cookie should be once for all subdomains..