cookie、localstorage、sessionstorage区别

cookie大小仅有4k左右
cookie由服务器生成,可设置失效时间,默认是浏览器关闭后失效。
与服务器通信,每次都会携带在http头中,如果使用cookie保存过多信息会导致性能问题。

localstorage
大小为5M
除非被清除,否则永久保存。
仅在客户端保存,不参与服务器信息交互。

sessionstorage
大小为5M
仅在当前页面有效,关闭页面或浏览器后被清除。
仅在客户端中保存,不参与服务器交互。

猜你喜欢

转载自blog.csdn.net/qq_42535651/article/details/103332619