javascript - I do not know what is the cookie's path? how to find it? - Stack Overflow

function setCookie(name, value){var times = 30;var exp = new Date();exp.setTime(exp.getTime() + times *

 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 part name + "=" + 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
 |  Show 1 more ment

1 Answer 1

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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信