hey, I have this script which set a cookie, but the expiring of the cookie is session only. Can somebody help my modifie this script so the cookie is good for a long time (maybe a few months, or a specific date like 2170 or so? this is the code I have <script type="text/javascript"> function cookieSave(name, text) { document.cookie = name + "=" + escape(text); } function cookieLoad(name) { var search = name + "="; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search); if (offset != -1) { offset += search.length; end = document.cookie.indexOf(";", offset); if (end == -1) { end = document.cookie.length; } return unescape(document.cookie.substring(offset, end)); } } } </script> Code (markup): Thanks, Dries
Try something like: var now= new Date() var expireDate= new Date() expireDate.setTime(now.getTime() + 60*60*24*365*1000) //1000 because time is in milliseconds setCookie("http://www.mysite.com", name, expireDate) -Darrin