How apps remember you
You log in. You click something. The server has no idea who you are.
HTTP is stateless: every request arrives fresh, with no memory of the one before it and no built-in way to connect the two. The login that succeeded a second ago left nothing behind.
So an app that needs to recognise you across requests has to put identity somewhere and get it back on every request that follows.
The whole of this section is one question: where does identity live?
Almost every login flow on the web answers it in one of three ways.
The server remembers
In stateful identity, the server keeps the information.
When you log in, the server creates a session, a small bundle of data representing you: a user id, a name, maybe a role. That session lives on the server. The browser gets a cookie carrying a session id, nothing more, and sends it automatically with every request to that domain. The server takes the id, looks up the session, and knows who you are again.
This is the traditional web app pattern, and the default in a lot of frameworks. If you've used express-session, this is what it was doing.
Everything that matters about you stays on the server, and the id is only useful to someone who can also reach that server.
The client carries the proof
In stateless identity, the server stores nothing about you.
The client holds a token and sends it with every request. The server checks the token and answers, without looking anything up about who you are between requests.
That works well for APIs, mobile apps and distributed systems, where shared server memory is awkward or unavailable. If you've ever called an API and received 401 Unauthorized: missing authorization header, that's this model telling you to bring your proof.
There are two versions of it, and the difference matters enough that they get a chapter each. An opaque bearer token is a meaningless random string the server looks up. A JSON Web Token carries the identity inside itself, signed, so no lookup is needed at all.
It still has a database full of users. What it stops keeping is a record of the fact that you are currently logged in.
Somebody else vouches for you
In delegated identity, a third party you trust confirms who the user is on your behalf.
Your app asks Google whether it recognises this person. Google runs the login and hands your app a token proving the answer. Every "Sign in with Google", "Sign in with GitHub" and "Sign in with Apple" button is this.
The appeal is that you stop running a password system. No password storage, no reset flow, no breach of credentials you never held. OAuth and delegated identity covers how the handover actually works.
That's why you get bounced to a Google page and then back again. The proving happened over there.
Side by side
| Stateful | Stateless | Delegated | |
|---|---|---|---|
| Where identity lives | On the server | In the token the client holds | With the provider |
| Cost per request | A lookup | A signature check, or a lookup | Depends on the token you end up using |
| Revoking access | Immediate | Hard, usually waits for expiry | Partly the provider's decision |
| Scales sideways | Needs a shared store | Freely | Freely |
| Main thing you give up | Coordination between servers | The ability to change your mind | Control and independence |
None of them is the right answer. They optimise for different things, which is why real systems often run more than one: a delegated login to establish who you are, a session for the website, tokens for the API.
The one line worth carrying into the next chapter: stateful is for control, stateless is for scale, delegated is for handing the problem to someone else.
Try it
For each system, name the model you'd expect and the one property that decides it.
- An internal admin dashboard where revoking someone's access has to take effect immediately.
- A public API serving a mobile app with a few hundred thousand users.
- A photo app whose entire signup is a "Continue with Google" button.
- A microservice architecture where a dozen services each need to know who is calling.
Compare your answers
| # | Model | The deciding property |
|---|---|---|
| 1 | Stateful | Immediate revocation. Delete the session and the next request is anonymous. Nothing else offers that. |
| 2 | Stateless | No shared session store to coordinate as traffic grows, and mobile clients hold a token comfortably. |
| 3 | Delegated | No password system to build, store or breach, and the fastest possible signup. |
| 4 | Stateless, specifically JWTs | Each service can verify the token itself without asking a central server on every call. |
Number 1 is the interesting one. It's the smallest system on the list and the one with the least scaling pressure, and it still gets the model that scales worst, because control matters more here than growth does.
Where this goes next
Three families, one problem each solves differently.
Sessions and cookies takes the first one apart: what the server stores, what the browser carries, and the mistakes that turn a solid model into a leaky one.

