Skip to content

Instantly share code, notes, and snippets.

@allenhwkim
Created April 18, 2020 06:14
Show Gist options
  • Select an option

  • Save allenhwkim/fb4b48b1a3ae3f256c2db33d529910ff to your computer and use it in GitHub Desktop.

Select an option

Save allenhwkim/fb4b48b1a3ae3f256c2db33d529910ff to your computer and use it in GitHub Desktop.
print all sessionStorage and localStorage data
var i;
document.write('<h2>local storage</h2>');
for (i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
const value = localStorage.getItem(key);
document.write(`<li> <b>${key}</b>: ${value}</li>`);
}
document.write('<h2>session storage</h2>');
for (i = 0; i < sessionStorage.length; i++) {
const key = sessionStorage.key(i);
const value = sessionStorage.getItem(key);
document.write(`<li> <b>${key}</b>: ${value}</li>`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment