Edit in JSFiddle

// Set the value in sessionStorage
sessionStorage.setItem("firstname", "Shanid");

// get the value from sessionStorage
var fname = sessionStorage.getItem("firstname");
document.getElementById("output1").innerHTML = fname;


// Set the value in localStorage
localStorage.setItem("firstname", "KV");

// get the value from localStorage
var fname = localStorage.getItem("firstname");
document.getElementById("output2").innerHTML = fname;
 
<div>First Name: <span id="output1"></span></div>
<div>Last Name: <span id="output2"></span></div>