/* function to set the value of the specifed cookie*/ function setCookie(name, value, expires, path, domain, secure) { var expString = ((expires == '') ? ' ' : ('; expires=' + expires.toGMTString())); var pathString = ((path == '') ? ('; path=/') : ('; path=' + path)); var domainString = ((domain == '') ? ' ' : ('; domain=' + domain)); var secureString = ((secure == true) ? '; secure' : ''); document.cookie = name + '=' + value + expString + pathString + domainString + secureString; } /* function to extract the current cookie from the cookie arr*/ function getCookie(name) { var start = document.cookie.indexOf(name+"="); var len = start+name.length+1; if ((!start) && (name != document.cookie.substring(0,name.length))) return null; if (start == -1) return null; var end = document.cookie.indexOf(";",len); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(len,end)); } /* Delete a cookie */ function deleteCookie(cookiename) { var exp = new Date(); exp.setTime(exp.getTime() - 1); var cookieVal = getCookie(cookiename); if (cookieVal != null) document.cookie = name + "=" + cookieVal + "; expires=" + exp.toGMTString(); return; }