Local storage: cookie, localStorage, sessionStorage.
cookie: an attribute under the document object.
The type is " small text file ", which is the data (usually encrypted) stored on the user's local terminal by some websites in order to identify the user's identity and perform Session (session control) tracking. The information is temporarily or permanently saved by the user's client computer. .
let cookie ={
// 写入/修改cookieset(key,value,expires){
let d =newDate(expires);
document.cookie = key +"="+ value +";expires="+d;},// 读取cookieget(key){
let arr = document.cookie.split("; ")var result ={
}
arr.forEach(item=>{
let key = item.split("=")[0];let value = item.split("=")[1];
result[key]=value;})return key?result[key]:result;},// 删除cookieremove(key){
if(this.get(key)){
document.cookie = key +"=18;expires="+newDate('1999-09-09');returntrue;}else{
returnfalse;}}}
localStorage: It is used to save the data of the entire website for a long time. The saved data has no expiration time until it is manually deleted.