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=/" represents cookie's path is what? and if delete "path=/", cookie's path is what?
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=/" represents cookie's path is what? and if delete "path=/", cookie's path is what?
Share Improve this question edited Jan 15, 2017 at 7:56 Superman asked Jan 15, 2017 at 7:04 SupermanSuperman 2855 silver badges17 bronze badges 6- 1 Is it some javascript poem? Regarding path you cannot access it from code – Vinay Commented Jan 15, 2017 at 7:13
- @Novice, This is js code; I want to find the cookie, where is the cookie? Thanks for your reply – Superman Commented Jan 15, 2017 at 7:25
- I want to know where the cookie file locates – Superman Commented Jan 15, 2017 at 7:59
-
1
That's what I am saying friend .While storing cookies by you supply all stuff but when you try to read by using
document.cookie
it will only give this partname + "=" + encodeURI(value)
And path does not refer to your system's path but rather path relative to website.for eg. if cooki is set for path like google/mypony then it will be used only on that page – Vinay Commented Jan 15, 2017 at 8:01 - Thank you very much! I feel know your mean. you mean that js cookie file can not be found, because it do not store system's path. is this? – Superman Commented Jan 15, 2017 at 8:14
1 Answer
Reset to default 4"path=/"
means
path is set, you can access cookie
name
anywhere in your application/domain (http://localhost or http://example.)
"path=/"
is not set means
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
Check this links
https://developer.mozilla/en-US/docs/Web/API/Document/cookie
http://www.quirksmode/js/cookies.html
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745306907a4621765.html
评论列表(0条)