jquery cookie - hoursToLive

Posted by mathiregister on Stack Overflow See other posts from Stack Overflow or by mathiregister
Published on 2010-03-16T15:59:26Z Indexed on 2010/03/16 16:01 UTC
Read the original article Hit count: 270

Filed under:
|

Hi guys, i'm using the jquery cookie plugin. Everything works fine except the fact that I have no idea how to set an expiration-time for the cookie?

$.cookie('opt_visible', 'true');

the jquery-cookie documentation says:

hoursToLive (DEPRECATED for expiresAt)

  • NUMBER
  • For how many hours should the cookie be valid? (Passing 0 means to delete the cookie at the end of the browser session--this is default. Negative values will delete the cookie, but you should use the del() method instead.)

That's exactly what I'd like to have. The cookie should be available as long as i'm browsing the site. As soon as i close the window or browsertab, the cookie should be deleted.

How can i implement this hoursToLive thingy to my mentioned line above?

Thank you

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about cookie