Back to Scripts page
Click in the text area below, select all and copy to grab the script
Script listing:
<HTML> <HEAD> <TITLE>Handling more than one cookie</TITLE> <SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT"> <!-- Hide script from older browsers now = new Date expireDate = new Date expireDate.setMonth(expireDate.getMonth()+6) hitCt = eval(cookieVal("pageHit")) hitCt++ lastVisit = cookieVal("pageVisit") if (lastVisit == 0) { lastVisit = "" } document.cookie = "pageHit="+hitCt+";expires=" + expireDate.toGMTString() document.cookie = "pageVisit="+now+";expires=" + expireDate.toGMTString() function cookieVal(cookieName) { thisCookie = document.cookie.split("; ") for (i=0; i<thisCookie.length; i++) { if (cookieName == thisCookie[i].split("=")[0]) { return thisCookie[i].split("=")[1] } } return 0 } // End hiding script --> </SCRIPT> </HEAD> <BODY BGCOLOR=WHITE> <H2> <SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT"> <!-- Hide script from older browsers document.write("You have visited this page " + hitCt + " times.") if (lastVisit != "") { document.write("<br>Your last visit was " + lastVisit) } // End hiding script --> </SCRIPT> </H2> </BODY> </HTML>