So far this behavior is in Chrome and Firefox (latest versions of each).
Let’s say we set some cookies with the following JavaScript:
document.cookie = "is_halloween=true";
document.cookie = "skeletons=spooky";
Now let’s break the rules and do this:
document.cookie = "BOO";
If we check the value of document.cookie
in the console, it looks like this:
is_halloween=true; skeletons=spooky; BOO
What exactly is BOO
? If we try to remove it with the following code, nothing happens:
document.cookie = "BOO=;expires=Thu, 01 Jan 1970 00:00:00 GMT;";
document.cookie
is still equal to is_halloween=true; skeletons=spooky; BOO
If we set document.cookie
to an empty string:
document.cookie = "";
document.cookie
is still equal to is_halloween=true; skeletons=spooky; BOO
Questions:
1. Is this special behavior in document.cookie
intended to be used as a free text field for custom cookie syntax? If so, is it documented anywhere?
2. How do I get rid of BOO
? The normal method of setting the expires
field isn’t working.
Edit: BOO
can be removed with document.cookie="Boo;expires=Thu, 01 Jan 1970 00:00:00 GMT"