The Auldridges

Blessed Beyond Reason

JavaScript Cookie Library

Filed under: Technology — by Jim on November 2, 2005 @ 12:39 pm

Technorati Tags : , , ,

Close on the heels of my Generic AJAX Library I have written a cookie handling library.

For those not aware, a cookie is a small bit of data that a developer can leave on your PC to ‘rememember’ things. This technology was enabled because of the stateless nature of HTTP–the protocol that web pages are transmitted in. It allows programmers to leave information, such as your login preferences, on your computer to remember what your preferences were next time you come back to the site.

Most all web development languages and environments have methods of accessing and manipulating these bits of data, but JavaScript’s is very limited. You can read from and write to the document.cookie string, but all of the actual data formatting or interpreting is left to you to do manually.

This being the case, I have been wanting to write an OOP based version of a library that provides this functionalty to programmers in the JavaScript environment. Others have done the same in the past, and I am not claiming mine is much better. But I didn’t find everything that I was personally looking for in the ones I saw out there, and I love writing things myself. My friend Dustin has mentioned it before, and I agree with him–sometimes it’s better, even more fun, to re-invent the wheel. It also doesn’t hurt to get more examples of such code out there to help others who are Googling about hopelessly needing something like this. ;)

So, I’ll leave you to my demonstration page for the Cookie Library, better known as cookieLib. Enjoy!

Powered By Qumana

9 Comments

  1. Jeff:

    Very nice Jim. Now you just have to get DMS to work. ;o)

  2. Jim:

    If I could only develop the passion for DMS that I have for JavaScript! ;)

  3. ChristianGeek:

    Awesome, sometimes reinventing the wheel is fun

  4. Dustin Diaz:

    Jim, this is great… and it makes so much more sense. No more flustering with 5 separate functions just lying around in my js files. You can definitely count on me stealing this. It might even find it’s way into some big sites ;)

  5. Jim:

    Thanks Dustin! You get my name into the ears of the folks that run those big sites, and you can use anything I write anytime you want! ;)

  6. Shawn C:

    Looking sweeeet! Keep up the good work.

  7. Jeph:

    huh? I’m confused…but I do like cookies.

  8. Jim:

    mmmm…cookies. :)

  9. The Auldridges » Update to the JavaScript Cookie Library:

    […] Several months ago, I wrote a JavaScript library for cookie interaction. I have now updated it to version 1.1. […]

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.