Back to Scripts page
Click in the box below, select all and copy to grab the script
<HTML> <HEAD> <TITLE>Handling more than one cookie</TITLE> <SCRIPT LANGUAGE=JAVASCRIPT> <!-- Hide script from older browsers // This script copyright 1997, Tom Negrino and Dori Smith. // This script is from "JavaScript for the WWW, Visual QuickStart Guide, 2nd Ed." // For more information, see <http://www.chalcedony.com/javascript/>. // This script may be used and modified, but the copyright notice must remain intact. now = new Date expireDate = new Date expireDate.setYear(expireDate.getYear()+1) hitCt = 0 lastVisit = "" if (document.cookie != "") { cookieArray = document.cookie.split(";") if (cookieArray[0] != "") { hitCt = eval(cookieArray[0].split("=")[1]) } if (cookieArray[1] != "") { lastVisit = cookieArray[1].split("=")[1] } } hitCt++ document.cookie = "pageHit="+hitCt+";expires=" + expireDate.toGMTString() document.cookie = "pageVisit="+now+";expires=" + expireDate.toGMTString() // End hiding script --> </SCRIPT> </HEAD> <BODY BGCOLOR=WHITE><H1> <SCRIPT LANGUAGE=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></H1> </BODY> </HTML>