The following code works if I make a single change: replacing localStorage with sessionStorage.
localStorage
sessionStorage
Can someone explain why? To my knowledge, they a