In plain words
A server-side session is a sign-in your server remembers and can delete at any time; a JWT is a signed token that carries the sign-in with it, valid until it expires unless you check something revocable.
Where you see it
A Harbor customer reports a stolen laptop and asks you to sign them out everywhere. With sessions in the database you delete their rows and it's done. With 30-day JWTs and nothing else, every copied token keeps working for up to a month.
What goes wrong
- Long-lived JWTs with no way to revoke them
A token that lasts 30 days stays valid after a password change, a sign-out or a stolen laptop. Keep access tokens short, and keep the revocable part, a session or refresh token, on the server.
- Tokens in localStorage
Any script running on the page, including injected code or a compromised package, can read localStorage and send the token away. An HttpOnly cookie can't be read by scripts, which limits what an XSS bug can steal.
- Letting the token choose how it's checked
Libraries that trusted the token's own algorithm header have accepted unsigned or wrongly signed tokens in the past. Pin the algorithm, and check issuer, audience and expiry on every request.
jwt.verify(token, publicKey, { algorithms: ["RS256"], issuer: "https://auth.harbor.example", audience: "harbor-api" });
What to tell your agent
Quick check
Sign in to earn +10 XP for itHarbor issues 30-day JWTs and checks only their signature. A customer changes their password after a phishing scare. What happens to the stolen token?