cookie sessionStorage localStorage

cookie:只在特定url下有效

sessionStorage:浏览器关闭则失效

localStorage:手动删除则失效,否则一直保留

Cookie



$.cookie('key','value');
$.cookie('key');

sessionStorage


window.sessionStorage.setItem('key','value');
window.sessionStorage.getItem('key');

//如果未引入jq,用js
sessionStorage.setItem('key','value');
sessionStorage.getItem('key');

localStorage


window.localStorage.setItem('key','value');
window.localStorage.getItem('key');

//如果未引入jq,用js
localStorage.setItem('key','value');
localStorage.getItem('key');

 

你可能感兴趣的:(jquery,cookie,javascript)