DEV Community

[Comment from a deleted post]
Collapse
 
ethanarrowood profile image
Ethan Arrowood

So for session storage you have two options, localStorage and sessionStorage:

"sessionStorage is similar to Window.localStorage, the only difference is while data stored in localStorage has no expiration set, data stored in sessionStorage gets cleared when the page session ends" - MDN

More info can be found here

Both of these are client side only.

Cookies on the other hand are predominantly used for server-side data recording. StackOverflow

The biggest difference is that cookies are sent via the HTTP protocol where localStorage just writes to the Window Storage API implemented by several browsers such as Chrome and Firefox.