简体   繁体   English

我不希望使用javascript为我的cookie设置特定路径

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

I am setting a cookie, but I don't want it to just work for one directory. 我正在设置一个cookie,但是我不希望它仅适用于一个目录。 How do I make it to where it's read throughout my whole site? 如何在整个网站上读取它? I'm pretty new at JavaScript, thanks guys! 我对JavaScript非常陌生,谢谢!

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

路径/

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想以一种非常具体的方式修改 Javascript 中的数组,但我不知道如何 - I want to modify an array in Javascript in a very specific way and i don't know how to 我不想刷新页面或控制台! JavaScript表单处理 - I don't want my page or console to refresh! Javascript form handling 我不知道为什么我的JavaScript函数Flip()不返回任何东西。 我希望它返回是正面还是反面 - I don't know why my function Flip() in JavaScript isn't returning anything. I want it to return if it is heads or tails 如何仅使用javascript创建单选按钮(我不想使用html标签)? - How to create a radio button using only javascript (I don't want to use html tags)? 我不希望我的表单在提交后刷新 - i don't want my form to refresh after i submit Javascript显示/隐藏-我不希望它隐藏整个元素 - Javascript show/hide - I don't want it to hide the entire element JavaScript 似乎存储了我不想存储的答案 - JavaScript seems to store answers I don't want stored 我想从函数中调用javascript函数,但是它不起作用 - I want to call javascript function from function, but it don't work 我不想在javascript上重复相同的代码**新** - I don't want to repeat the same code on javascript **new ** javascript 当我不想要它时将整数转换为字符串 - javascript converting ints to strings when I don't want it to
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM