Created
December 31, 2013 16:45
-
-
Save anoxic/8199386 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // From: https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage | |
| // SESSION STORAGE | |
| sessionStorage.setItem('fullname', 'John Paul'); // defining the session variable | |
| alert("Your name is: " + sessionStorage.getItem('fullname')); // accessing it | |
| alert("Hello " + sessionStorage.fullname); // another way of accessing the variable | |
| sessionStorage.removeItem('fullname'); // finally unset it | |
| sessionStorage.clear(); // removes all keys | |
| // LOCAL STORAGE | |
| localStorage.setItem('fullname', 'John Paul'); // defining the localStorage variable | |
| alert("Your name is: " + localStorage.getItem('fullname')); // accessing it | |
| alert("Hello " + localStorage.fullname); // another way of accessing the variable | |
| localStorage.removeItem('fullname'); // finally unset it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment