Bill's Cookie Code

So a guy named Bill Dortch put together some JavaScript that deals with cookies in an efficient manner. The impressive thing is that not only does the code work well, but he wrote it in 1996 and it's still good! He even included fixes for Netscape 2 on the Mac, which isn't something you'll find in many contemporary scripts. When was the last time you had Netscape 2 on your Mac?

Bill's code has a few functions:

  • SetCookie (creates a cookie)

  • DeleteCookie (deletes a cookie)

  • GetCookie (returns a displayable cookie value)

  • getCookieVal (does some of the work for GetCookie)

  • FixCookieDate (for those Mac/Netscape 2 browsers)

We won't look at the entire code right now, mostly because it's quite long (but mostly due to comments). We'll start ...

Get Advanced JavaScript™: Insights and Innovative Techniques 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.