JavaScript: Cookie-less Session Data

no-cookie

Sometimes you need to be able to pass data between pages using JavaScript. For this, you can use cookies with all the limitations associated to them or you can use a nasty trick. The window.name variable will survive between page loads, so, if you write something into this variable, it will be available after a page reload 🙂 . Of course you can’t use this for sophisticated or secure data, but for temporary parameters it’s OK.

Example

window.name = "This message will survive between page loads";

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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