Comment: In html5, we have provided a local cache mechanism, which will replace our cookies, and it will not be posted with the browser. The cache in our server-side html5 mainly includes localStorage and sessionStorage. For details, please read this article
In html5, we have a local cache mechanism that will replace our cookies and will not send them to our server side with the browser. We can use js to operate local cache freely on the client. The cache in html5 mainly includes localStorage and sessionStorage. Their usage is consistent. The difference is that their time limits are different. There is no time limit for localStorage. The sessionStorage data storage is now based on the session, and the data will be deleted after closing or leaving the website.Let's take a brief look at the official example operation:
javascript
localStorage.fresh = vfresh.org; //Set a key value
var a = localStorage.fresh; //Get key value
Or use its API:
javascript
//Clear storage
localStorage.clear();
//Set a key value
localStorage.setItem(fresh,vfresh.org);
//Get a key value
localStorage.getItem(fresh);
//return vfresh.org //get the name of the key to the specified subscript (like Array)
localStorage.key(0);
//return fresh //delete a key value
localStorage.removeItem(fresh);
There is no need to talk nonsense, it is equivalent to our expiration time Expire=0 cookie;