01 May 2009

Fun with Cookie Expiration

So, I had a bit of code that would delete a cookie if the date that I set it ("sessionTimeBegan", which I stored in a variable) turned out to be on the previous day as when I was checking it:

if (MDM.VARS.MAIN.sessionTimeBegan.clearTime(true) <
(new Date()).clearTime())
{
// delete cookie
}

Then I remembered that you can just set cookies to expire on a certain time and date and that this is utterly stupid.

Don't do this.

That being said, I did learn about ExtJS's "clearTime()" and "clone()" functions for Date objects, and they're really neat.

No comments:

Post a Comment