//Use localStorage for that. It's persistent over sessions. //Writing : localStorage['myKey'] = 'somestring'; // only strings //Reading : var myVar = localStorage['myKey'] || 'defaultValue'; //If you need to store complex structures, you might serialize them in JSON. For example : //Reading : var stored = localStorage['myKey']; if (stored) myVar = JSON.parse(stored); else myVar = {a:'test', b: [1, 2, 3]}; //Writing : localStorage['myKey'] = JSON.stringify(myVar); //Note that you may use more than one key. They'll all be retrieved by all pages on the same domain. //Unless you want to be compatible with IE7, you have no reason to use the obsolete and small cookies.
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter