How does jquery resolve cookie deletion failure?

Source: Internet
Author: User

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;
});
});

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.