AlgoPlusAlgoPlus
AlgoPlus//web / sessions-login
Read the theory

Cookies, Sessions & Login

How a website remembers who you are across stateless requests — credentials in, a session cookie out, and a quiet hello on every request after.

Step
Legend
Active in this exchange
AI Tutor Workspace
In a nutshell
HTTP is stateless — each request is independent and remembers nothing — so a site needs a trick to keep you logged in. When you submit your password, the server verifies it, creates a session (a record of who you are) in its own store, and replies Set-Cookie: session=<id>. The browser saves that cookie and automatically attaches Cookie: session=<id> to every later request, so the server looks the id up and knows it's still you. The cookie only carries an opaque id; the real data stays server-side. A token/JWT is the alternative, where the signed cookie carries the identity itself.
Ready
Press play to begin the cinematic walkthrough.
HTTP forgets you between requests. So at login the server hands the browser a cookie holding a session id; the browser shows that cookie on every later request, and the server uses it to recognise you.
Key terms
Go deeper in the lesson
Read the full theory, intuition & complexity for Cookies, Sessions & Login.