-
Notifications
You must be signed in to change notification settings - Fork 0
Cookie vs localStorage vs sessionStorage
Ivy1994 edited this page Nov 3, 2020
·
1 revision
cookie
document.cookie = 'token' + '110';
console.log(document.cookie);
localStorage and cookieStorage: sessionStorage.setItem(name,value); sessionStorage.getItem(name); sessionStorage.valueof()
Cookie: 可以设置失效实现,没有设置的话,默认关闭浏览器后失效 localStorage: 除非手动清除,否则可以永久保存 sessionStorage:仅当前会话下有效
Cookie: 4KB 左右 localStorage and sessionStorage: 5MB
cookie:每次都会携带在 HTTP 头中 localStorage and seesionStorage:仅在客户端中,不参与服务器的通信