gpt4 book ai didi

javascript - JS cookie : cannot set path

转载 作者:行者123 更新时间:2023-12-01 03:54:16 25 4
gpt4 key购买 nike

这两个语句都无法将 cookies 路径设置为所需的值:

 $.cookie('name', 'value', { path: "abc/de" });
document.cookie = "username=John Smith; expires=Thu, 18 Dec 2013 12:00:00 UTC; path=abc/de";

实际路径始终设置为 Controller :

enter image description here

背景:我有两个剑道网格,我想将其选定的元素存储在 cookie 中。不知何故,我需要区分仅路径不同的两个网格。

这不应该正是 ment 的路径吗?

最佳答案

参见the specification :

If the attribute-name case-insensitively matches the string "Path",the user agent MUST process the cookie-av as follows.

If the attribute-value is empty or if the first character of the
attribute-value is not %x2F ("/"):

  Let cookie-path be the default-path.

Otherwise:

  Let cookie-path be the attribute-value.

Append an attribute to the cookie-attribute-list with an attribute-name of Path and an attribute-value of cookie-path.

由于路径的第一个字符是 a 而不是 /,因此该值无效并被忽略。

您必须提供绝对路径(例如 /foo/bar/abc/de)。

关于javascript - JS cookie : cannot set path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42902989/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com