Js存储数据到LocalStorage并设置过期时间
setLocal = function (key, val) { var prefix = "project_list_"; key = prefix + key; var expires = 600; val = JSON.stringify({'val': val, 'expires': new Date().getTime() + expires * 1000}); localStorage.setItem(key, val); }; getLocal = function (key) { var prefix = "project_list_"; key = prefix + key; var val = localStorage.getItem(key); if (!val) { return null; } val = JSON.parse(val); if (val.expires < new Date().getTime()) { localStorage.removeItem(key); return null; } return val.val; };