In the past we were setting our cookies without the 'domain' option (using the cookie plugin) e.g:
$.cookie("blah", "1", {
expires: 365,
path: "/"
});
Now we are setting it like:
$.cookie("blah", "1", {
expires: 365,
path: "/",
domain: ".site.com"
});
However the problem is there are 2 cookies with the same name set for users who already have the old cookie on the page.
As a solution, at the point of setting the new cookie I am doing:
$.cookie("blah", null, {
path: "/"
});
Which should dele开发者_运维知识库te the cookie without the 'domain' option. Otherwise when reading the cookie it could give me the old value as there may be 2 set with the same name.
Do you think this is an ok workaround? I tested it in Firefox and it works fine as I haven't specified the domain part so it shouldn't delete the new cookie, just the old, however I am worried it could happen maybe on older browsers like IE6 or on mobiles (we get a lot of mobile traffic)?
Any guidance would be great!
seems fine :) I believe it should work in every case.
精彩评论