开发者

I don't want a specific path for my cookie using javascript

开发者 https://www.devze.com 2022-12-18 14:00 出处:网络
I am setting a cookie, but I don\'t want it to just work for one directory. How do I make it to where it\'s read throughout my whole site? I\'m pretty new at JavaScript, thanks guys!开发者_Python百科

I am setting a cookie, but I don't want it to just work for one directory. How do I make it to where it's read throughout my whole site? I'm pretty new at JavaScript, thanks guys!

开发者_Python百科
<script>
function setCookie(val) {

   var d = new Date();
   d.setDate(d.getDate() + 300);
   document.cookie = "roster_count" + "=" + escape(val) + "; expires=" + d.toGMTString();

   delete d;
}
</script>


The the path /:

document.cookie = "roster_count" + "=" + escape(val) + "; expires=" + d.toGMTString() + "; path=/";
0

精彩评论

暂无评论...
验证码 换一张
取 消