使用JQuery操作cookie时 发生取的值不正确的问题:
结果发现cookie有四个不同的属性:
名称,内容,域,路径
$.cookie('the_cookie'); // 读取 cookie
$.cookie('the_cookie', 'the_value'); // 存储 cookie
$.cookie('the_cookie', 'the_value', { expires: 7 }); // 存储一个带7天期限的 cookie
$.cookie('the_cookie', '', { expires: -1 }); // 删除 cookie
使用:
$.cookie("currentMenuID", menuID); 时 未指定域和路径。
所有当域和路径不同时会产生不同的cookie
$.cookie("currentMenuID"); 取值时会产生问题。
故:
$.cookie("currentMenuID", "menuID", { path: "/"});
进行覆盖。同域下同一个cookieID对应一个值。
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn