PDA

View Full Version : set an expiration date for javascript cookies in accordion menu?



college4sale
12-10-2010, 07:42 PM
1) Script Title: Bullet Accordion Menu
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu-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!

jscheuer1
12-11-2010, 07:21 AM
In the ddaccordion.js file, replace:


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

with:


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=/';
},