brwoser storage examples
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: javascript save data to local storage
// Store
localStorage.lastname = "Smith";
// Retrieve
document.getElementById("result").innerHTML = localStorage.lastname;
// Remove
localStorage.removeItem("lastname");