Authentication proves who a user is; a session remembers that proof across requests. A secure session uses an unpredictable identifier, server-side expiry, protected cookies, and explicit logout or revocation.
Authentication proves who a user is; a session remembers that proof across requests. A secure session uses an unpredictable identifier, server-side expiry, protected cookies, and explicit logout or revocation.
| Question | Practical answer |
|---|---|
| When is it useful? | After login, a server stores session state and sends an HttpOnly, Secure, SameSite cookie; later requests present the cookie without exposing the password again. |
| What should you do? | Sketch login, authenticated request, expiry, logout, and stolen-cookie scenarios for a tiny notes app. |
| How do you know it worked? | Expired or revoked sessions cannot access protected routes, cookies are unavailable to client JavaScript, and password changes invalidate sensitive sessions. |
| Common failure | Do not store raw passwords or long-lived session secrets in localStorage; hashing passwords and protecting sessions solve different problems. |
flowchart LR
A[Question] --> B[Authentication and sessions]
B --> C[Small example]
C --> D[Evidence]
The important idea is not to stop at a definition: connect the concept to a small example and observable evidence.
After login, a server stores session state and sends an HttpOnly, Secure, SameSite cookie; later requests present the cookie without exposing the password again.
Before acting, write the success signal. Change one condition at a time, observe the result, and record assumptions. For Authentication and sessions, this separates what you know from what you are merely guessing.
Goal: Sketch login, authenticated request, expiry, logout, and stolen-cookie scenarios for a tiny notes app.
Expected result: Expired or revoked sessions cannot access protected routes, cookies are unavailable to client JavaScript, and password changes invalidate sensitive sessions.
Do not store raw passwords or long-lived session secrets in localStorage; hashing passwords and protecting sessions solve different problems.
When the result differs from your prediction, do not change many things at once. Check inputs, versions, environment, permissions, and logs, then repeat from the smallest example.
Use the linked resource or repository at the end of the page when you need a full implementation. Check current versions before applying commands to a real project.
Set up a Next.js project from scratch and understand the App Router.
A beginner-friendly map of how websites work, what to learn first, and how to practise by building one small product.
A browser resolves a domain through DNS, opens a protected connection with HTTPS, sends an HTTP request, receives resources from a server or CDN, and renders them while JavaScript may request more data.