Courses / Frontend Security & Observability
12. Token storage patterns
Tradeoffs between storing tokens in cookies, localStorage, and in-memory for JavaScript apps.
JavaScript
Token storage patterns
Where and how you keep authentication tokens (cookies, localStorage, or in-memory) so your web app stays both usable and secure.
"I need my app to remember who the user is without letting attackers steal their session."
Token storage patterns are the tradeoffs between storing auth tokens in cookies, localStorage, or only in memory, balancing persistence, XSS risk, and CSRF risk. Choose storage based on your threat model: persistent convenience vs. limiting exposure to attackers.
"I need my app to remember who the user is without letting attackers steal their session."
Token storage patterns are the tradeoffs between storing auth tokens in cookies, localStorage, or only in memory, balancing persistence, XSS risk, and CSRF risk. Choose storage based on your threat model: persistent convenience vs. limiting exposure to attackers.