Tim, the Enchanter

What manner of man are you that can summon up code without C# or Java?

Monday, March 17, 2008

 

Who ate my cookie! (and other puns about browser cookies)

Recently I learned, on accident, how to create a session cookie in JavaScript (which was causing a bug in the Campfire Growl Script).

  function setCookie(name, value) { document.cookie = (name + "=" + escape(value)); }

Here's how to NOT create a session cookie:

  
  function setCookie(name, value, days) { 
    expire_str = days ? ";expires="+(new Date(new Date().getTime() + days*24*60*60*1000)).toGMTString() : ""
    document.cookie = (name + "=" + escape(value)) + (expire_str); 
  }

HINT: Specify an expiration date on the cookie

If the campfire growl script is forgetting your settings, update to the latest :)


Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

Archives

March 2008   April 2008   May 2008   June 2008   July 2008   August 2008   October 2008   November 2008   February 2009   June 2009   December 2009   January 2010   February 2010   May 2010   June 2010   November 2010  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]