Tony's Cookie Example

The alert boxes show the functions running as the result of the logic in the document.

"checkCookie()" determines if you've ever been here before. Our purpose is to recognize repeat visitors and differentiate them from unique visitors. Upon every reload of the document checkCookie() increments the visit counter.

"setCookie()" sets up your identity. The first time you visit the site without our cookie, a 10-digit random tracking number is installed on your computer, as well as the date of your visit, and a visit counter value of "1". Try crushing the cookie and reloading the page.

"getCookie()" grabs the cookie already installed in your computer, and parse the string into values we can use. Even though I named the values such things as "firstName", "lastName", etc. we only plan to address these values by their array number anyway.

"sortCookie()" takes the split cookie string and sorts them in alphabetical order based on their name. All this is supposed to do is help us organize the cookie information in a common order so we can address it later on.

The buttons do different things, which should be self explanatory.