Old news, right? Well, I've been getting away with this for a while and not realizing it, in logic to expire cookies, and didn't notice until switching to Chrome.
The cookie expiration function was something like this
Date d = new Date(); d.setYear(d.getYear() - 1); // last year = 110 document.cookie = "COOKIE_NAME=; expires=" + d.toGMTString();
Firefox was happily setting the cookie's expiration to the year 0110, which was wrong but still accomplishing the end goal of expiring the cookie.
Chrome, on the other hand, mangled toGMTString to only print the three digits "110" and was not interpreting the cookie as expired.
Of course, the better question is why write this code yourself anyway, when jQuery, Dojo, etc., all have their own cookie APIs.
No comments:
Post a Comment