cookie和session localStorage和sessionStrorage

cookie是①存储在本地浏览器②<4kb

        获取: request.cookies.get(key, '默认值');

       设置 : resp.set_cookie(key, value , max_age=)

session是①存储在服务器②存储在服务器端的数据更加安全③会占用服务器的资源

localStorage:(属于永久存储)  解决cookie存储空间不足的问题(<5M)     >IE8  只支持string类型的存储

sessionStrorage: (当会话结束时,sessionStrorage中的键值对会被清空)

localStorage读取与写入  https://www.cnblogs.com/st-leslie/p/5617130.html

var storage = window.localStorage;

写入:

storage["a"] = 1;

storage.a = 1;

storage.setItem("c",3);

读取:

var a = storage.a;

var b = storage["b"];

var c = storage.getItem("c");

 

 

你可能感兴趣的:(cookie和session localStorage和sessionStrorage)