Result of :
After a click on the above link, the expected result is
'Hello World'
. Safari 12.1.1 or Safari for iOS 12.3.1, however,
usually show null
(unless using the workaround from below).
sessionStorage
or
localStorage
are accessed “too early.” In that case, they
appear disconnected from the persistent storage for the entire time the user
stays on the current page. This can also be seen in the Web Inspector.
https://bugs.webkit.org
and then return to
(since this
URL has no query parameter, sessionStorage
is not accessed
during page load). The Web Inspector will show that Session Storage is not
empty. In fact, the first click on the link at the top of this page (when
the Session Storage was not accessed too early) properly created an entry.
A workaround is for the JavaScript code to wait before accessing the storage. To verify, enter a wait time here (50ms or more should work) and click the link at the top of the page again: