Results 1 to 3 of 3

Thread: Changing from session cookie to permanent cookie

  1. #1
    Join Date
    Mar 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Changing from session cookie to permanent cookie

    1) Script Title: Switch Menu

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...switchmenu.htm

    3) Describe problem: I'm trying to make it so that when a user selects a navigation item, it sets a permanent cookie and will remember their choice from session to session. Currently it will do a session-only cookie. Does this seem possible?

    My working sample is here: http://www.ktvb.com/blocks/nnuslide/test.html

    Thanks!
    Last edited by boisemedia; 03-21-2008 at 07:45 PM.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Try changing the line:

    Code:
    document.cookie=cookiename+"="+cookievalue
    inside the script to something like:

    Code:
    var expireDate = new Date()
    expireDate.setDate(expireDate.getDate()+30)
    document.cookie = cookiename+"="+cookievalue+"; expires="+expireDate.toGMTString()
    30 here means the cookie will persist for 30 days.

  3. #3
    Join Date
    Mar 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Perfect

    Worked like a charm. thank you!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •