当我第一次访问我的商店时,我显示了时事通讯弹出窗口。如果我关闭 弹出窗口在我清除缓存或 cookie 之前不会再出现。
这在我的主商店中运行良好。但在我的子商店中,即使我关闭弹出窗口,它也会显示在下一页中。
我已经检查了主商店和子商店的不同 cookie 变量名称。
我还通过更改 magento 后端中的 cookie 路径和 cookie 域进行了检查。
但没有任何效果。Cookie 在我的子商店中无法正常工作。
我在主商店网址后使用/wholesale 来访问我的批发商店,而不是使用批发网站的特定域。
请帮我解决我的问题。
//set cookie
function setCookie(cname,cvalue,exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname+"="+cvalue+"; "+expires;
}
最佳答案
我通过设置特定于子商店的 cookie 路径解决了这个问题。
//set cookie
function setCookie(cname,cvalue,exdays) {
var url = window.location.pathname;
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires=" + d.toGMTString();
if(url.indexOf('wholesale') > -1) {
document.cookie = cname+"="+cvalue+"; "+expires+";path=/wholesale";
} else {
document.cookie = cname+"="+cvalue+"; "+expires;
}
}
关于magento - Cookie 不适用于 magento 子商店,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37188927/