What are the technical pros and cons of localStorage, sessionStorage, session and cookies, and when would I use one over the other?
LocalStorage
Pros:
Cons:
Cookies
Pros:
Cons:
The data is sent back to the server for every HTTP request (HTML, images, JavaScript, CSS, etc) - increasing the amount of traffic between client and server.
Typically, the following are allowed:
sessionStorage
Pros:
localStorage
.Cons:
localStorage
, it works on same-origin policy. So, data stored will only be available on the same origin.Checkout across-tabs - how to facilitate easy communication between cross-origin browser tabs.