Dev note: This page needs improving.
Secure Storage
localStorage is vulnerable to XSS attacks and should not be used for storing sensitive tokens in production applications.
-
HttpOnly Cookies (Most Secure)
- Protected from XSS attacks
- Automatic CSRF protection when configured properly
- Handled automatically by browsers
-
Web Workers + IndexedDB
- Isolated from main thread
- Protected from XSS
- More complex implementation
-
In-Memory Storage
- Cleared on page refresh
- Protected from XSS
- Requires state management solution
Server-Side Configuration
Your server should set cookies with secure options:Security Best Practices
- Always use HTTPS for token transmission
- Set appropriate cookie flags:
- HttpOnly
- Secure
- SameSite=Strict
- Implement CSRF protection
- Use short token expiration times
- Rotate refresh tokens