localStorage

Html5 is a new local cache scheme, currently used more, generally used to store ajax returned data, speed up the next page when the rendering speed.

/ / localStorage core API: localStorage.setItem(key, Localstorage.getitem (key) localStorage.removeItem(key) LocalStorage.clear () // Delete all records under this domain nameCopy the code

sessionStorage

Similar to LocalStorage, but will be deleted when the browser is closed,

Cookie

Data stored (usually encrypted) on a user’s local terminal by a web site for identification and session tracking purposes.

Cookies are typically sent to the server side together in the header of an HTTP request.

A cookie record is mainly composed of key, value, field, expiration time and size. The general user saves user authentication information.

Document.cookie () to get all the cookies

SetCookie(” Cookie “, “cookievalue”,time()+3600, “/forum”, “.learnphp.cn “, 1);

Delete the Cookie

To delete an existing Cookie, there are two ways:

1, the SetCookie (” Cookie “, “”);

SetCookie(” Cookie “, “value”, time()-1 / time());

The specific differences between

The cookie mechanism maintains state on the client, while the session mechanism maintains state on the server