localStorage persists until explicitly cleared. sessionStorage clears when tab closes. Both store key-value pairs (5-10MB).
Solution Code
JavaScript
localStorage.setItem('key', 'value');
const data = sessionStorage.getItem('temp');
Explanation
Both use same API but different lifetimes. Data is domain-specific and strings-only.Guided Hints
How to store objects?
Security considerations