Skip to content

Instantly share code, notes, and snippets.

@svieira
Forked from remy/gist:726930
Created December 3, 2010 13:22
Show Gist options
  • Save svieira/726943 to your computer and use it in GitHub Desktop.
Save svieira/726943 to your computer and use it in GitHub Desktop.
if (!sessionStorage && JSON) {
sessionStorage = (function () {
var data = window.name ? JSON.parse(window.name) : {};
return {
clear: function () {
data = {};
window.name = '';
},
getItem: function (key) {
return data[key] === undefined ? null : data[key];
},
removeItem: function (key) {
delete data[key];
window.name = JSON.stringify(data);
},
setItem: function (key, value) {
data[key] = value;
window.name = JSON.stringify(data);
}
};
})();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment