[null, {"document_url": "http://dreamerslab.com/blog/en/javascript-session/", "unformatted_src": "http://farm6.static.flickr.com/5295/5512310721_23a4f5c6fe.jpg", "src": "http://farm6.static.flickr.com/5295/5512310721_23a4f5c6fe.jpg", "formatted_filename": "a f c fe"}, null, {"document_url": "http://dreamerslab.com/blog/en/javascript-session/", "unformatted_src": "http://farm6.static.flickr.com/5294/5512226025_5b6b43a3f6.jpg", "src": "http://farm6.static.flickr.com/5294/5512226025_5b6b43a3f6.jpg", "formatted_filename": "b b a f"}, null, {"document_url": "http://dreamerslab.com/blog/en/javascript-session/", "unformatted_src": "http://farm3.static.flickr.com/2146/2261209016_19729a3aa6_m.jpg", "src": "http://farm3.static.flickr.com/2146/2261209016_19729a3aa6_m.jpg", "formatted_filename": "a aa m"}, null, {"document_url": "http://dreamerslab.com/blog/en/javascript-session/", "unformatted_src": "http://farm4.static.flickr.com/3154/3347768206_8f232307e6_m.jpg", "src": "http://farm4.static.flickr.com/3154/3347768206_8f232307e6_m.jpg", "formatted_filename": "f e m"}, null, {"document_url": "http://dreamerslab.com/blog/en/javascript-session/", "unformatted_src": "http://farm4.staticflickr.com/3170/2738211580_01055557d6_m.jpg", "src": "http://farm4.staticflickr.com/3170/2738211580_01055557d6_m.jpg", "formatted_filename": "d m"}, null]
Javascript session

javascript javascript session session

Store your session data in window.name

For a long time I thought there is no such a thing call `session` in javascript, all variables and function will be clear after the page is reloaded. Not until I found this tiny javascript session library wrote by Craig Buckler.

Let’s take a look at the source code


Basically what it does is storing all your variables in json string format in the `window.name` property which does not change when your browser goes to another page. Very clever move!!

There is also another javascript session library call `sessvars` which does the same thing but with more options. You might want to take a look at it if you have advance usage of javascript sessions.


This demo is also made by Craig Buckler.

 jQuery blockUI alternative with jQuery MSG plugin Google image search style image alignment with jQuery Atteeeeention plugin Javascript callbacks Javascript `this` Write a todo list with Express and MongoDB