My current web application is experiencing an issue with session storage. Whenever I navigate to a different URL within the same tab, it seems like the session storage is being cleared.
Let me walk you through the situation:
I initially store some data in session storage using
.session storage.set('key', 'value')
Next, I move to another URL in the same tab by using
window.location.href ='url'
.Upon arriving at the new URL, I attempt to retrieve the stored data with
sessionStorage.get('key')
, however, it returns null.
This behavior is rather perplexing because ordinarily, session storage should remain intact within the same tab until either the tab is closed or the session ends.
The relevant function in my web app is named:
sessionStorageSyncReducer
return localStorageSync({})
clearState(reducer)
I have thoroughly investigated my code for any inadvertent deletion of session storage entries but to no avail. Could there be a specific reason behind the unexpected clearing of session storage? Is there perhaps a method to guarantee that session storage remains persistent even when switching to another URL within the same tab?