localStorage.setItem("lastname","smith"); //SET OR UPDATE
localStorage.getItem("lastname"); //GET
localStorage.lastname = "smith"; //SET OR UPDATE
localStorage.removeItem("lastname"); //REMOVE
localStorage.clear(); //REMOVE ALL
//expiry 做法
var hours = 24;
var now = new Date().getTime();
var setupTime = localStorage.getItem('setupTime');
if(setupTime == null){
localStorage.setItem('setupTime', now);
}
else{
if(now - setupTime > 1000 * 600){ //1000是ms, 600即是600秒(10分鐘)
localStorage.clear();
localStorage.setItem('setupTime', now);
}
}