简体   繁体   English

jQuery cookie无法在IE中运行

[英]jQuery cookies not working in IE

I'm setting cookies using jquery-cookies and appending a comma on every entry so it looks like this: 我正在使用jquery-cookies设置cookie并在每个条目上添加逗号,所以它看起来像这样:

"ee337,ee389,ee347,etc." “ee337,ee389,ee347,等等。”

I'm doing this like this: 我是这样做的:

if($.cookie('oswfav') == null){
    $.cookie('oswfav', id, {expires: 365});
} else {
    var curCook = $.cookie('oswfav');
    $.cookie('oswfav', curCook+','+id, {expires: 365});
}

In Firefox/Chrome, this works fine and they get appended correctly. 在Firefox / Chrome中,这样可以正常工作并且可以正确添加。 However in IE, it works the first time (the first ID comes in fine) but adding more to the cookie doesn't work. 但是在IE中,它第一次工作(第一个ID很好),但添加更多的cookie不起作用。 I've tried setting them with PHP cookies too and got the same result. 我也试过用PHP cookie设置它们并获得相同的结果。

Is there something I'm missing/need to set for IE to work? 有什么我缺少/需要设置IE工作?

I am not 100% sure if it will solve your pbm but give a try to this, use ; 我不是百分百确定它是否会解决你的pbm,但试试这个,使用; as separator. 作为分隔符。

I am also re-writing your code in a little different way 我也以一种不同的方式重新编写代码

if($.cookie('oswfav')){
    var newCook = $.cookie('oswfav') + ';' + id;
    $.cookie('oswfav', newCook, {expires: 365});
} else {
    $.cookie('oswfav', id, {expires: 365});
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM