Cookie is set twice; how to remove the duplicate?

Dude(tte), there are inconsistencies, and a bug, in your cookie setter.

1. Make sure path and domain is correctly set

The path and domain should be the same for both clearing the cookie and setting it. See your code here:

document.cookie = c_name + "=; expires=Fri, 31 Dec 1999 23:59:59 GMT;";

and compare it to:

var c_value=escape(value) + "; expires=" + exdate.toUTCString(); + "; path=/spring; domain=aroth.no-ip.org";

you will see that the setter has both of them, but the deleter doesn't. You will bring about chaos.

2. Oh, and that nasty semicolon

That second line of code I quoted above, has a semicolon introduced in the middle of a string concatenation expression. Right after exdate.toUTCString(). Kill it. Kill it…now.

At least on my Google Chrome, I managed to get it run correctly, if I set a breakpoint at json = "[" + json + "]"; and modify setCookie before it is executed.

P/S: It was a bizzare debugging experience, where I managed to set 4 layoutState cookies, by fiddling with path & domain.


This may be too simple, but just in case, are the cookies recorded for two different paths? If the URL is different, you may be setting your cookies for a restricted path, so the system would take them differently.