在 JavaScript 中保存 cookie 值时如何设置路径? [英] How do I set path while saving a cookie value in JavaScript?

查看:35
本文介绍了在 JavaScript 中保存 cookie 值时如何设置路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ASP 页面上保存了一些 cookie 值.我想设置 cookie 的根路径,以便 cookie 在所有页面上都可用.

I am saving some cookie values on an ASP page. I want to set the root path for cookie so that the cookie will be available on all pages.

当前cookie路径为/v/abcfile/frontend/

Currently the cookie path is /v/abcfile/frontend/

请帮帮我.

推荐答案

只需:document.cookie="name=value;path=/";

它有一个负面

现在,cookie 将可用于域中的所有目录设置自.如果该网站只是该域中的众多网站之一,则它是最好不要这样做,因为其他人也可以访问您的 cookie 信息.

Now, the cookie will be available to all directories on the domain it is set from. If the website is just one of many at that domain, it’s best not to do this because everyone else will also have access to your cookie information.

这篇关于在 JavaScript 中保存 cookie 值时如何设置路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆