Describe the difference between cookies, sessionStorage and the localStorage

(A) the same point: are stored in the client

(Ii) differences:

1. The storage size different
cookie data size can not exceed 4k.
Although sessionStorage and localStorage storage size is also limited, but is much larger than the cookie, you can reach 5M or greater.

2. Effective time different
localStorage to store persistent data, the browser is closed after data is not lost unless the initiative to delete data;
sessionStorage data is automatically deleted after the current browser window is closed.
valid until the expiration date cookie cookie settings, even if the window or browser is closed

3. The interaction between the different data with the server
cookie data is automatically transmitted to the server, the server can also write cookie to client
sessionStorage and localStorage not automatically send data to a server, saved only locally.

Guess you like

Origin www.cnblogs.com/yisen996/p/11511061.html