Cannot save cookie with jQuery and Internet Explorer 9

假如想象 提交于 2020-01-10 06:09:06

问题


it seems I'm not able to set a cookie on IE9 and I don't understand the cause. My goal is to set a cookie which expires after a year, and I'm using the following code

$.cookie( name, value, { expires:days } )

where days is equal to 365. The cookie I've got is gone as soon as the session expired ( i.e. close and open the browser ) I've also tried with the following code but nothing changed

function setCookie( name, value, days ) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + days);
    var c_value = value + ( ( days==null ) ? "" : "; expires="+exdate.toUTCString() + "; path=/");
    document.cookie=name + "=" + c_value;
}

Is there something IE9 doesn't like (e.g. some characters)? Please give me a hand with this stuff.

Best Regards MB


回答1:


I found that the problem seems to be tied to the Browser configuration. I've got a dive here:

  1. Open Internet Explorer 9
  2. Click on the Tools icon on the very right at the top and then on Internet Options.
  3. At the top switch to the tab Privacy and click on the Advanced button.
  4. Allow First-Party Cookies and Third-Party Cookies and enable Session Cookies.

All works fine now.

Could you confirm that there is nothing I can do about it but warn my users at most?



来源:https://stackoverflow.com/questions/16985834/cannot-save-cookie-with-jquery-and-internet-explorer-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!