There is a difference b/w sessionStorage and localStorage.
The sessionStorage is available only for that particular session i.e if a browser is reloaded, you will no longer be able to access the data. However, localStorage is persistent and will be available until you explicitly remove it.
If the value is empty, you need to check the value of data[0].
localStorage.setItem('mytest', 'Check the local storage console');
console.log(localStorage.getItem('mytest'));