A function has been developed recently, but it always becomes invalid when the cookie is deleted. Why is it unclear.
When $. cookie ("name", "") is used, a new null cookie is generated.
Use $. cookie ("name", null), and delete the cookie.
Last use$. Cookie ("name", null, {path :"/"});Finally succeeded.
It may be a bug of $. cookie. I wonder if the latest version has fixed this Bug.
Some other $. Cookies are reproduced by the way for backup:
Copy codeThe Code is as follows:
$ (Function (){
Var COOKIE_NAME = 'test _ cooker ';
// Set the cookie through the interval
$ ('A'). eq (0). click (function (){
$. Cookie (COOKIE_NAME, 'test', {path: '/', expires: 1 });
Return false;
});
// Set the cookie and expiration time
$ ('A'). eq (1). click (function (){
Var date = new Date ();
Date. setTime (date. getTime () + (1x24x60*60*1000 ));
$. Cookie (COOKIE_NAME, 'test', {path: '/', expires: date });
Return false;
});
// Obtain the cookie
$ ('A'). eq (2). click (function (){
Alert ($. cookie (COOKIE_NAME ));
Return false;
});
// Delete the cookie
$ ('A'). eq (3). click (function (){
$. Cookie (COOKIE_NAME, null, {path :'/'});
Return false;
});
});