DeepFrontend
Learning Paths
Practice
System Design & DS
Design Studio
Data Structures Curriculum
Real-World Case Studies
Careers
Job Board
Resume Builder
Blog
Sign in
Search
⌘K
Go Pro
Loading compiler resources...
HTML Quiz Practice
Active Recall Drill Session
← Exit Session
Question 1 of 1
medium
HTML
Why is an HttpOnly cookie safer than localStorage for storing an auth token, specifically with respect to XSS?
A
HttpOnly cookies are encrypted automatically
B
HttpOnly cookies are completely inaccessible to JavaScript (document.cookie can't read them), so injected malicious script from an XSS bug cannot read and exfiltrate the token
C
HttpOnly cookies expire faster than localStorage values
D
localStorage is not supported in modern browsers
Check Answer