标签: cookie-path

JQuery cookie扩展将使用路径设置cookie但不会读取它

首先,设置一个cookie:

jQuery.cookie('monster', 'big', { path : '/sesame/'});
Run Code Online (Sandbox Code Playgroud)

接下来,尝试阅读它:

jQuery.cookie('monster');
Run Code Online (Sandbox Code Playgroud)

Firefox告诉我,cookie确实已经设置好了.值是big,路径是/sesame/.然而,当我试图读取cookie时,它将无法工作.

问题的替代版本:如何在读取 cookie 时指定路径?

作为一个实验,我使用了以下语法,但它设置了一个cookie而不是一个cookie.

$.cookie('cookie_name', { path: '/path/' });
Run Code Online (Sandbox Code Playgroud)

javascript jquery jquery-plugins jquery-cookie cookie-path

10
推荐指数
2
解决办法
5245
查看次数

如何设置AntiForgeryToken cookie路径

不推荐使用允许覆盖它的以前的HtmlHelper.AntiForgeryToken方法string path.

[ObsoleteAttribute("This method is deprecated. Use the AntiForgeryToken() method instead. To specify a custom domain for the generated cookie, use the <httpCookies> configuration element. To specify custom data to be embedded within the token, use the static AntiForgeryConfig.AdditionalDataProvider property.", 
    true)]
public MvcHtmlString AntiForgeryToken(
    string salt,
    string domain,
    string path
)
Run Code Online (Sandbox Code Playgroud)

告诉你使用<httpCookies>.但httpCookies元素没有PATH的设置.

这是对这种方法的弃用的疏忽吗?覆盖此cookie路径的最佳方法是什么?(手动?)在虚拟应用程序中运行网站不会隐式地将应用程序路径添加到__RequestVeririfcation cookie.

asp.net-mvc csrf antiforgerytoken cookie-path asp.net-mvc-5.2

6
推荐指数
1
解决办法
2322
查看次数

设置Cookie路径JavaScript

我希望下面的代码设置root的路径,我知道我必须设置/作为路径值,但这不是我的代码,我不熟悉Javascript!

function setCookie(name, value, expires, path, domain, secure){

document.cookie= name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
Run Code Online (Sandbox Code Playgroud)

我已经尝试过如下编辑代码但是没有成功.

 setCookie(name, value, expires, path, domain, secure){

document.cookie= name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path="/") +
((domain) ? "; …
Run Code Online (Sandbox Code Playgroud)

javascript cookies cookie-path

5
推荐指数
1
解决办法
2万
查看次数