html5 web storage code example

Example 1: local storage

function setItem(name, value) {
  localStorage.setItem(name, value);
}
function getItem(name) {
  localStorage.getItem(name);
}
function deletItem(name) {
  localStorage.removeItem(name);
}
function clearStorage() {
  localStorage.clear();
}

Example 2: localstorage

localStorage.setItem('name', 'Bob') // make/set a key/value
var username = localStorage.getItem('name') // get the key
console.log(username) // log the key
// This data will be saved even after you close the page