function setCookie(name, value)
{
var times = 30;
var exp = new Date();
exp.setTime(exp.getTime() + times * 24 * 60 * 60 * 1000);
document.cookie = name + "=" + encodeURI(value) + ";expires=" + exp.toUTCString() + ";path=/";
}
“path=/”代表cookie的路径是什么?如果删除“path=/”,cookie的路径是什么?
最佳答案
"path=/"
表示
path is set, you can access cookie
name
anywhere in your application/domain (http://localhost or http://example.com)
"path=/"
未设置意味着
path is not set, then cookie
name
is save just for the directory(also include its child directory)
in which current page belongs to, you can't access it on another directory
检查此链接
https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
关于javascript - 不知道cookie的路径是什么?如何找到它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41658684/