Handling Multiple Cookies
You will often want to deal with more than one cookie at a time, and Script 10.8 shows you how to read from more than one cookie and display the information. This example shares a fair amount of code with the “Using Cookies as Counters” example.
To handle multiple cookies:
1. | var lastVisit = cookieVal("pageVisit"); | |
2. | if (lastVisit == 0) { lastVisit = ""; } Script 10.8. Use an array to deal with multiple cookies in a single script.
|
Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh 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.