Code
Execute
<!DOCTYPE html> <html> <head> <title>Wikitechy Web Storage in HTML5</title> </head> <body> <h2> HTML Web Storage</h2> <p><button onclick="setStorage()" type="button">Set</button></p> <p><button onclick="getStorage()" type="button">Get</button></p> <p><button onclick="removeStorage()" type="button">Remove</button></p> <script> function setStorage() { localStorage.setItem("name", "wikitechy"); sessionStorage.setItem("name", "wikitechy"); } function getStorage() { alert("Local Storage:" +localStorage.getItem("name") + "Session Storage:" + sessionStorage.getItem("name")); } function removeStorage() { sessionStorage.removeItem("name"); localStorage.removeItem("name"); } </script> </body> </html>
Result