1.Cookie, LocalStorage, sessionStorag

Common: Both can be used to store data;

[Cookie introduction]

Because HTTP is a stateless protocol, it cannot save the state of every request, and “Cookie” has the magical feature that can be saved on the client, so it is necessary to add cookies to the client to save the state of the client.

Function of Cookie: to achieve the function of recording user personal information and state management function;

The Cookie life cycle is generally generated by the server and the expiration time can be set. If the Cookie is generated on the browser, it will expire after the browser is closed by default. The size of a data store does not exceed 4KB, and the number of data stores does not exceed 20.

[localstroage introduction]

Localstroage is local storage and the life cycle is permanent. Even if the browser is closed, the data will not disappear unless deleted. It stores no more than 5M of data, and there is no limit on the number of data.

[sessionstroage introduction]

Sessionstroage is the session storage. The life cycle is browser-dependent. When the browser page or page is closed, the data disappears. It stores no more than 5M of data, and there is no limit on the number of data.