【问题标题】:JQuery removeCookie not working on Internet Explorer 7JQuery removeCookie 在 Internet Explorer 7 上不起作用
【发布时间】:2017-08-06 07:16:07
【问题描述】:

我有以下sn-p的代码

jQuery.removeCookie("foo", { path: '/foo' });

这在 chrome 中运行良好,但在 IE 中没有删除 cookie。当我在 chrome 中检查 cookie 时,我可以看到它位于路径 /foo 下。我也尝试了以下调用,路径上带有斜杠,并且根本没有选项参数,但不要让它在 IE 中工作。

如何删除 IE 中的 cookie?

【问题讨论】:

  • 当您说“我在路径/foo 下看到它”时,您是指cookie 路径还是页面URL?您使用的是哪个 jQuery cookie 库?
  • 我的意思是 chrome cookie 窗口中提到的路径。例如,JSESSIONID 有一个路径“/”。我正在使用 jQuery Cookie 插件 v1.4.0。删除 cookie 的库实现如下$.removeCookie = function (key, options) { if ($.cookie(key) === undefined) { return false; } // Must not alter options, thus extending a fresh object... $.cookie(key, '', $.extend({}, options, { expires: -1 })); return !$.cookie(key); };

标签: javascript jquery internet-explorer cookies


【解决方案1】:

根据您的 jQuery 版本,这通常有效:

$.cookie("name", null, { path: '/' });

【讨论】:

    猜你喜欢
    • 2012-06-07
    • 2012-07-31
    • 2011-12-07
    • 1970-01-01
    • 1970-01-01
    • 2011-01-25
    • 1970-01-01
    • 2019-08-12
    • 1970-01-01
    相关资源
    最近更新 更多