Cookie, sessionStorage, localStorage

Cookie, sessionStorage, localStorage is stored in the client, session object data is stored in the server actually browser and server only need to pass the session ID. The server finds the corresponding user session object based on the session-ID. Sessions are safer for storing user information. Browsers are only suitable for storing general data

2. Cookie data is always carried in the HTTP request of the same origin and transmitted back and forth between the browser and the server. Session-id, sessionStorage and localStorage are stored locally only

3, size limit difference, cookie data does not exceed 4KB, localStorage in Google Browsing 2.6MB

4. Data validity period is different. Cookies are valid within the set (server setting) validity period, regardless of window and browser closing

5, sessionStorage is only valid before the current browser window is closed, close namely destroy (temporary storage), localStorage is always valid

SessionStorage localStorage

SessionStorage is used to store data in a session locally. The data can only be accessed in the page using a session (that is, during the first communication) and the data will be destroyed after the session ends. SessionStorage is not a persistent local storage, session level storage

2. LocalStorage a localStorage used for persistence that will not expire unless data is deleted