sessionStorage and cookies are all client storage solutions which store data as key/value pairs in the browser.
sessionStorage both extend Storage. There is no difference between them except for the intended “non-persistence” of
sessionStoragemaintains a separate storage area for each given origin that’s available for the duration of the page session (as long as the browser is open, including page reloads and restores)
localStoragedoes the same thing, but persists even when the browser is closed and reopened.
both the above storages can be accessed using global variables
Cookie on the other hand is used to store data that has to be sent back to the server with subsequent requests. Cookies are primarily for reading server-side,
sessionStorage can only be read on the client-side.