Does inside the page mean the browser window? Browser tab? Website domain?
Website domain.
The read-only
sessionStorageproperty accesses a sessionStorageobject for the current origin.sessionStorageis similar tolocalStorage; the difference is that while data inlocalStoragedoesn't expire, data insessionStorageis cleared when the page session ends.
reference: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
The
localStorageread-only property of thewindowinterface allows you to access aStorageobject for theDocument's origin;
localStorageis similar tosessionStorage, except that whilelocalStoragedata has no expiration time,sessionStoragedata gets cleared when the page session ends — that is, when the page is closed. (localStoragedata for a document loaded in a "private browsing" or "incognito" session is cleared when the last "private" tab is closed.)
reference: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
Any script running in the page (Google Analytics for example) can access both localStorage and sessionStorage.
If you are willing to use JWT for managing sessions, please read this article and its references at the end: