The World Wide Web is both the gateway to a marvelous universe and a gaping portal for invasion. So our browsers are understandabely paranoid about our invited guests' access to our storage media. 'Cookies' are the exception to the rule. They allow visiting web pages to save and retrieve information in your computer. You can capture the process and refuse the information or let it happen sight unseen. There are limits on cookies - no more than 300 cookies, no cookie larger than 4K, no more than 20 cookies per domain.
What are these snippets for? They allow a web page to deposit a piece of information that persists until its defined expiration date. The only required information is the name and its value. [Cookies without dates last only until the end of the session]. So a visitor can leave a date, and thereby know when you revisit a site. Or a commercial site can use nondated cookies for its 'shopping basket'. Or you can store persistent variables between sessions. etc.
The JavaScript cookie guru is Bill Dortch, who wrote the JavaScript Functions we've all used to manage cookies. The Oxherder's version in the source code are adaptations of his code:
- setCookie(name, value, [expiration date], [secure]):
- The setCookie function requires only the first two arguments [three if it is to persist]. They are the name of the cookie; the value of the cookie; the expiration date [in days from today]; and 'true' if a secure channel is required.
- getCookie(name)
- The getCookie function returns the specified cookie's value [or null if it doesn't exist].
- deleteCookie(name)
- The deleteCookie function deletes the specified cookie by setting its expiration date to the current date.