Explainer

You Log In Once. The Server Forgets You After That.

By Felix Maru · November 21, 2026 · 7 min read

There is a small lie at the heart of every website you use. When you type your password and click Sign In, it feels like you have established a relationship with that server: it knows you, it recognises you, it remembers you. That feeling is real in a practical sense. But the technology underneath works nothing like that, and understanding the actual mechanism is one of those things that quietly changes how you think about internet security forever.

Every Request Starts Blank

The protocol that moves web pages around is called HTTP. It was designed, deliberately, to be stateless. That is not a bug or an oversight. It is a core design decision from the early 1990s, chosen because it makes the web simpler, faster, and easier to scale.

What stateless means in practice: when your browser sends a request to a web server, that request arrives with no memory attached. The server processes it and sends back a response. Then it forgets the exchange entirely. The next request from your browser arrives just like the first one, as a stranger walking through the door for the first time.

Think of it like a shop staffed by a clerk with absolute amnesia. Every time you walk in, they have no idea whether you have been there before, what you bought yesterday, or whether you have already paid for a tab. Each visit is a fresh start from zero.

This creates an obvious problem: if you just proved your identity by typing your password, and the server immediately forgets that, how does the next page you request know you are still you?

The Token That Bridges the Gap

The fix is a small piece of data called a session token, and your browser carries it on every request after you log in.

Here is the sequence: you submit your username and password. The server checks them against its records and, if they match, creates a unique random string, something like a9f3c8d2e..., essentially a long random ID that maps to your account in the server's memory. The server sends that string to your browser inside a cookie, a small named piece of data the browser is instructed to store and send back automatically with future requests to that domain.

From that point on, every request your browser makes to that site carries the cookie, quietly, in the background, without you seeing it. The server reads the token, looks it up, finds your account attached to it, and knows who you are. The amnesia is solved not by giving the server a memory, but by giving you a wristband to show at the door each time.

The analogy I find clearest: a festival wristband. At the gate you show your ticket and ID, the staff verify you, and they snap a wristband on your wrist. For the rest of the day, you do not show your ID again. Every time you want a drink, enter a stage, or access a VIP area, you show the wristband. The wristband is what the cookie is. Your actual credentials never leave the entry gate.

What Actually Happens When You Log In

  1. You submit your credentials. Your browser sends your username and password over an encrypted connection.
  2. The server verifies them. It checks them against its records. If they match, authentication succeeds.
  3. A session is created. The server generates a random session ID, stores it mapped to your account, and attaches an expiry.
  4. The session ID is sent to your browser as a cookie. Your browser stores it, tied to that site's domain.
  5. Every subsequent request includes that cookie. The server reads it, finds your account, and treats the request accordingly.

Your actual password is never stored in the cookie and is never involved again. The session token is a temporary stand-in with no meaning outside that server's session store.

What Clicking "Log Out" Actually Does

Most people imagine that logging out somehow destroys a copy of their password on the server's side, or closes some kind of channel. Neither is true.

What logging out really does is simpler: it tells the server to delete the session record associated with your token. When your browser sends that cookie on the next request, the server looks it up, finds nothing, and treats you as unauthenticated. The cookie itself may still sit in your browser, but it no longer unlocks anything.

This matters for a few reasons. First, it explains why "log out from all devices" is a real, distinct action. Each device has its own session token stored in its own browser. Logging out from your laptop only invalidates that laptop's session. The session on your phone is a separate record on the server, still active, still valid. "Log out everywhere" invalidates all sessions in one operation, not just the current one.

Second, it explains why on shared or public computers, closing the browser tab is not the same as logging out. The cookie is still sitting in that browser's storage. Someone who opens the same browser and navigates to the same site may find themselves already authenticated. The session is still live on the server. Clicking Log Out is the action that ends it.

Cookies Do Not Mean Tracking (Necessarily)

The word "cookie" has acquired such negative connotations from privacy discussions that it is worth separating the concepts. A session cookie, the kind that keeps you logged in, is fundamentally different from a tracking cookie.

A session cookie is set by the site you are currently on, it contains only your session token, and it only gets sent back to that one site. It is essential for the site to function. Without it, you would have to log in on every single page load.

A tracking cookie, the kind that advertisers use, is set by a third-party domain embedded in many sites, an ad network or analytics provider. When you visit different sites that all load resources from the same ad network, that network's cookie tags along on each request and builds a picture of your browsing across unrelated sites.

Same mechanism, entirely different purposes. The regulations and browser features that block third-party tracking cookies largely leave session cookies alone, because blocking those would break almost every website on the internet.

The Security Part You Should Actually Care About

Because the session token is what gives access, stealing it is functionally equivalent to stealing a password. If someone obtains your session cookie, they can send requests to the server as you, without ever knowing your password. This attack has a name: session hijacking.

There are two practical defenses you benefit from, usually without thinking about them. The first is HTTPS: the encrypted connection between your browser and the server means the cookie cannot be read in transit by anyone watching the network. This is the real reason "public WiFi is dangerous" was such widespread advice. On an unencrypted connection, the session cookie travels in plain text, readable to anyone on the same network. On HTTPS, it is not.

The second defense is expiry. Session tokens are not permanent. Servers set them to expire after a period of inactivity, or after an absolute time limit. When the session expires on the server side, the token becomes useless regardless of whether anyone is still holding it. That is why banking sites log you out after a few minutes of inactivity: the session is invalidated server-side, and no saved cookie is any help after that.

One thing worth doing: check the active sessions list on your important accounts. Google, Microsoft, and most large services show every active session with device, location, and last activity. Any session you don't recognise is worth terminating.

The One Thing to Remember

The model most people carry, that a server "knows" you once you log in, is not wrong in a practical sense. But the actual machinery is stranger: the server forgets you instantly, and your browser earns a token that proves you already passed the gate. Everything that feels like a persistent relationship, your profile, your preferences, your cart, is that token being quietly presented on every click.

It explains why logging out from shared computers is worth the two seconds, why "log out everywhere" is the first step on a compromised account, and why a lost device logged into your email is an active risk until those sessions are revoked from the account settings.

If anything here raised questions about your own setup, or if you have an account access situation worth talking through, feel free to reach out.

Share 𝕏 in ✉

Comments