Concept
A session stores login state on the server and gives the browser a cookie id; a token, such as a JWT, carries the state itself and the server only verifies it. Each has different revocation, scaling and CSRF properties.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Sessions versus tokens doing its job.
Sessions Tokens (JWT)
- state in DB or cache - state inside the token
- revoke by deleting the row - revoke only by expiry or a blocklist
- cookie: httpOnly, SameSite - Authorization: Bearer header
- needs CSRF protection - no CSRF if not in a cookie
- fits browser apps - fits APIs and mobile clientsStoring a long-lived JWT in localStorage to avoid cookies. Any script injection reads it, and it cannot be revoked. Short-lived access tokens with an httpOnly refresh cookie is the usual compromise.
Your roadmap puts these before Sessions versus tokens, unless you already know them.
Once a session shows you understand Sessions versus tokens, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.
Topics that build on Sessions versus tokens.