Using Session Variables in Javascript without Cookies

Until a fully implemented HTML5 spec comes along and solves everyone’s problems, there are still some tricky issues to be dealt with when trying to store data on the client side. And of course, html5 wont be of much help when you’re still developing for older browsers. For example, take IE7 and it’s userdata implementation. It’s baffling and can be quite difficult to explain/understand.

In a recent implementation, I also found that it wasn’t persisting data across an entire website but only for particular pages. So I started to look for an alternative and found this implementation of session variables without using cookies.

Cookies are never a good thing and should be reduced at all costs. Remember that they get sent for every request from the domain, even for images and other static files so that’s using up a lot of bandwidth. Anyways, back to this very clever javascript implementation. This small script allows you to use session variables by manipulating the window object in javascript. It’s not incredibly secure but it is a very useful means for storing arbitrary pieces of data and is really incredibly clever.

This entry was posted in Web Development and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>