A web app stores session tokens in localStorage. A security audit flags this as a risk. What is the recommended alternative and why?
-
A
Store tokens in a JavaScript variable so they reset on refresh
-
B
Store tokens in HttpOnly cookies so JavaScript cannot access them, mitigating XSS theft
-
C
Base64-encode tokens before storing in localStorage
-
D
Store tokens in sessionStorage instead