Home > Web Front-end > JS Tutorial > Solution to Jquery operation cookie value error_jquery

Solution to Jquery operation cookie value error_jquery

WBOY
Release: 2016-05-16 17:24:21
Original
933 people have browsed it

The problem of incorrect values ​​occurred when using JQuery to operate cookies:
It turns out that cookies have four different attributes:
Name, content, domain, path

Copy code The code is as follows:

$.cookie('the_cookie'); // Read cookie
$.cookie('the_cookie', 'the_value'); // Store cookie
$.cookie('the_cookie', 'the_value', { expires: 7 }); // Store a cookie with a 7-day expiry date
$.cookie('the_cookie ', '', { expires: -1 }); // Delete cookie

Use:
$.cookie("currentMenuID", menuID); The domain and path are not specified.
All different cookies will be generated when the domain and path are different.

$.cookie("currentMenuID"); There will be problems when taking the value.
So:
$.cookie("currentMenuID", "menuID", { path: "/"});
overwrite. The same cookieID in the same domain corresponds to a value.
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template