Session Vars stashed in the Window?

I need to squirrel away some data in a way that will preserve the data between pages. I was using a cooke, but of course that sends it back to the server with each new request, and that’s bad for a variety of reasons. So I did a search and found this:

He explains the approach:

I make use of the fact that you can set the property through JavaScript – this is a property originally intended for naming windows and frames so that the you might address them by name in your scripts. In order not to interfere with this use in framesets (if anyone still uses them) my script only sets the property.

The big downside is that this information is stored & accessible to pages outside the domain, so if another web page knows to peek at, then that page can also see your data. Not safe!

The HTML5 localStorage is still a more attractive option, but I did think this approach was clever.

Here’s a good link talking about localStorage, and options for browsers that don’t support it:


Leave a comment

Filed under javascript, utility

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s