PDA

View Full Version : Changing from session cookie to permanent cookie



boisemedia
03-21-2008, 07:29 PM
1) Script Title: Switch Menu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/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!

ddadmin
03-21-2008, 09:38 PM
Try changing the line:


document.cookie=cookiename+"="+cookievalue

inside the script to something like:


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.

boisemedia
03-21-2008, 10:07 PM
Worked like a charm. thank you!