This assignment asks you to use cookies to keep track of whether or not a user has visited a web page. The solution below uses Webmonkey's cookie library to set and read a cookie named was_here.

<html><head><title>Chapter 12 Assignment</title> <script type = "text/javascript"> <!-- hide me from older browsers // this is from the webmonkey cookie library at http://www.webmonkey.com/ // function WM_readCookie(name) { if(document.cookie == '') { // there's no cookie, so go no further return false; } else { // there is a cookie var firstChar, lastChar; var theBigCookie = document.cookie; firstChar = theBigCookie.indexOf(name); // find the start of 'name' var NN2Hack = firstChar + name.length; if((firstChar != −1) && (theBigCookie.charAt(NN2Hack) ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.