scriptNode

Web development with a focus on JavaScript RSS

Simple Cookie Script

Novice Matt Hackett Published October 19th, 2008 by Matt Hackett

I often chat with a lot of new JavaScript developers. Many of their questions are really easy and can be answered with single-line responses, such as, "How do you append to an array?"

Easy stuff. What's unfortunate, though, is when the questions are a bit more involved, and these developers have already searched around a bit and found lousy code to read and learn from. The problem is that there's much ancient, awful JavaScript code out there, and when performing simple search queries, these sites come up. My goal is to improve this process.

One common topic is that of cookies. Dealing with cookies is really basic stuff, but hey, that's what the novice category is for. So here's a simple script to assist with managing cookies:

You can download this script below:

Also, PPK has an in-depth article about cookies. His code examples get the job done, but unfortunately create too many functions in the global scope (which, as we all know, should be avoided).

Read other articles tagged: , ,

Thoughts?

(required)

© 2009 scriptNode