Cookie path problem

Source: Internet
Author: User

The cookie was used in the development process yesterday, and when the $.cookie (' flag ', null) was destroyed, it was discovered and reborn as a cookie with the same name, with a value of NULL but with a different path.

It turns out that the cookie was not set to a path, so the cookie defaults to the path and path of the page, which is:
$.cookie ("flag", Data.count); is actually $.cookie ("flag", Data.count,{path: "/"});

But in getting the page code/yourendai/webroot/index/head_top.html

var flag= $.cookie (' flag ');
if (flag&&flag>0) {
$ ("#login_count"). HTML (flag);
$ ("#login_show"). Show ();
SetTimeout ("$ (' #login_show ')." Hide (); ", 3000);
$.cookie (' flag ', NULL);
}

The cookie for this page is actually a newly created $.cookie (' flag ', Null,{path: "/index"}); brutishness is an invalid cookie for/index

So two cookies are generated with the same name

Cookie path problem

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.