Results 1 to 2 of 2

Thread: set an expiration date for javascript cookies in accordion menu?

  1. #1
    Join Date
    Dec 2010
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default set an expiration date for javascript cookies in accordion menu?

    1) Script Title: Bullet Accordion Menu
    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...enu-bullet.htm
    3) Describe problem:


    How can I set an expiration date for the cookies in the ddaccordion.js file?

    I don't know javascript and was trying to figure it out using examples but I'm going in circles. Any help would be appreciated!!

    I'd like to set the cookies to expire in 24 hours.

    Thanks!
    Last edited by jscheuer1; 12-11-2010 at 07:30 AM. Reason: fix links

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    In the ddaccordion.js file, replace:

    Code:
    	setCookie:function(name, value){
    		document.cookie = name + "=" + value + "; path=/"
    	},
    with:

    Code:
    	setCookie: function(n, v, d){
    		d = 1; //number of days persistence
    		if(d){var dt = new Date(); 
    			dt.setDate(dt.getDate() + d);
    		d = '; expires=' + dt.toGMTString();}
    		document.cookie = n + '=' + v + (d || '') + '; path=/';
    	},
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    college4sale (12-11-2010)

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
  •