设置:
1 . $.session.set(‘token‘, result.accessToken) 这个要引用库jquerySession.js
2. sessionStorage.setItem("token", result.accessToken);
3. localStorage.setItem("token", result.accessToken);
获取:
1. ourtoken = $.session.get(‘token‘);
2. ourtoken = sessionStorage.getItem("token"); 这个同页面可以,跨页不行
3. ourtoken = localStorage.getItem("token"); 这个跨页也可以
添加数据
$.session.set(‘key‘, ‘value‘)
删除数据
$.session.remove(‘key‘);
获取数据
$.session.get(‘key‘);
清除数据
$.session.clear();
--------------------------------------
localStorage.a = 3;//设置a为"3"
localStorage["a"] = "sfsf";//设置a为"sfsf",覆盖上面的值
localStorage.setItem("b","isaac");//设置b为"isaac"
var a1 = localStorage["a"];//获取a的值
var a2 = localStorage.a;//获取a的值
var b = localStorage.getItem("b");//获取b的值
localStorage.removeItem("c");//清除c的值
参考:https://www.cnblogs.com/LChenglong/p/8006197.html
原文地址:https://www.cnblogs.com/c-x-m/p/10365006.html