The debate between JSON Web Tokens (JWTs) and traditional session cookies is a recurring fever dream in software engineering. It is not just a technical disagreement; it is a clash of architectural philosophies.
The False Dichotomy
If you spend enough time in developer forums, you will see the same fight every few months. One camp argues that JWTs are the future of scalable, modern architecture, while the other insists that traditional session management is the only way to maintain true control. The problem is that most people are arguing about the wrong thing. They treat JWTs and sessions as if they are mutually exclusive technologies, when in reality, they exist on different axes of design. A cookie is simply a transport mechanism—a way for a browser to store a value and send it back automatically. A session is a piece of state kept on your server, identified by an opaque ID. A JWT is a signed bundle of claims. You can actually put a JWT inside a cookie, or send a session ID in a header. The real disagreement isn't about the tool; it is about where the truth lives.
Where Does the Truth Live?
To understand why engineers fight, you have to ask: where does the source of truth reside? In a traditional session-based system, the truth lives on your server. When a user logs in, the server creates a record in a database or a memory store and hands the user a random, meaningless ID. When that user comes back, the server looks up that ID to see who they are and what they can do. This allows for instant control. If you want to kick a user off the system or change their permissions, you simply delete the session from your database. The change is immediate. In a JWT-based system, the truth lives inside the token itself. The token is a self-contained package of claims—like user ID, roles, and expiration time—that has been digitally signed. The server doesn't need to look anything up; it just verifies the signature. This is incredibly fast, but it creates a massive headache for security: if you want to revoke a token before it expires, you can't, because the server isn't checking a central list. The token is its own authority until it dies.
The Scalability Myth
The most common argument in favor of JWTs is scalability. Because the server doesn't have to perform a database lookup for every single request, you save precious milliseconds and reduce the load on your data stores. For massive, distributed systems, this is a legitimate advantage. However, there is a catch that many developers overlook. The moment your application requires real-time control—such as a 'log out of all devices' button or an immediate permission revocation after a security breach—the stateless advantage of the JWT evaporates. To make a JWT truly revocable, you end up having to build a 'deny list' or a database of revoked tokens. At that point, you have reintroduced the very stateful lookup you were trying to avoid. You have essentially built a session system using a more complex, heavier tool.
The Storage Trap
Another layer of the disagreement involves how the browser handles these credentials. There is a persistent temptation to store JWTs in 'localStorage' because it is easy for JavaScript to access. This is where security engineers get most vocal. If you store a token in localStorage, any malicious script running on your page—whether from a compromised third-party library or a cross-site scripting (XSS) attack—can read that token and steal it. On the other hand, traditional session IDs are typically stored in HttpOnly cookies. These are special because they are invisible to JavaScript. Even if an attacker manages to run a script on your site, they cannot reach into the cookie jar to grab the credential. This makes the choice of storage just as important as the choice of token type.








