无法使用jQuery和Internet Explorer 9保存Cookie

编程入门 行业动态 更新时间:2024-10-15 06:14:25
本文介绍了无法使用jQuery和Internet Explorer 9保存Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

似乎我无法在IE9上设置cookie,我不明白原因。 我的目标是设置一年后过期的cookie,并使用以下代码:

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

其中days等于365。我已经得到的cookie在会话过期(即关闭并打开浏览器)后消失我也尝试了下面的代码,但没有改变

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; }

有没有IE9不喜欢的东西

最好的祝福 MB

解决方案

我发现问题似乎与浏览器配置有关。 我在这里潜水了:

  • 打开Internet Explorer 9
  • 点击
  • 在顶部切换到隐私权标签,然后点击高级按钮。
  • 允许第一方Cookie和第三方Cookie并启用会话Cookie。
  • >

    你能确认我没有什么能做,但最多警告我的用户?

    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

    解决方案

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

  • Open Internet Explorer 9
  • Click on the Tools icon on the very right at the top and then on Internet Options.
  • At the top switch to the tab Privacy and click on the Advanced button.
  • 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?

    更多推荐

    无法使用jQuery和Internet Explorer 9保存Cookie

    本文发布于:2023-11-07 23:44:05,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1567756.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:Internet   jQuery   Cookie   Explorer

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!