The following code works if I make a single change: replacing localStorage with sessionStorage.
localStorage
sessionStorage
Can someone explain why? To my knowledge, they are identical in functionality and differ only in that sessionStorage is limited to a tab.
read(key: string): any { const item = localStorage.getItem(key); return JSON.parse(item); } write(key: string, value: any): void { localStorage.setItem(`${key}`, JSON.stringify(value)); }
1.4m articles
1.4m replys
5 comments
57.0k users