我正在尝试设置cookie及其路径,但无法正确设置路径

I am trying to set a cookie and its path but not able to set the path correctly

本文关键字:路径 设置 cookie      更新时间:2023-09-26

当我使用类似var值=取决于用户选择的某个数组。

document.cookie = "filters="+values;

如果路径是/abc def/

p>试试这个:
document.cookie="name=value;path=/";      

您可以使用

values=JSON.stringfy(values);document.cookie="filters="+值;

这将帮助您获得更多

$.cookie("test", 1, {
   expires : 10,           //expires in 10 days
   path    : '/',          //The value of the path attribute of the cookie 
                           //(default: path of page that created the cookie).    
   domain  : 'google.com',  //The value of the domain attribute of the cookie
                   //(default: domain of page that created the cookie).
   secure  : true          //If set to true the secure attribute of the cookie
                           //will be set and the cookie transmission will
                           //require a secure protocol (defaults to false).
});