Browser & Web Performance · Junior · Question 68 of 75
Why is storing an auth token in localStorage considered risky?
- ✓Correct answer: Any script running on the page, including injected XSS, can read it
- 2
localStorageis cleared every time the tab closes - 3
localStorageis sent to every server on each request
Explanation
localStorage has no HttpOnly equivalent. An HttpOnly, Secure, SameSite cookie keeps the token out of reach of JS.