Skip to content
BENIBIX Learn

Session vs JWT

A session keeps your login on the server, while a JSON Web Token carries it inside the token. With a session, the browser holds only an ID. The server looks it up on each request. A JWT holds the facts and a signature, so the server can check it with no lookup. A session can be ended at once; a JWT stays good until it runs out.

Development🔑 Auth

Session (Web)

How a site remembers you are logged in as you move from page to page.

A session is how a website remembers you are logged in from one page to the next. After you log in, the server makes a random session ID and keeps your details beside it. Your browser stores that ID in a cookie and sends it with every request. The server looks it up and knows it is you. Logging out deletes the session on the server.

Example
Emma logs in once and then opens 20 pages. Each request carries her session cookie, so she never has to log in again.
Why it matters
HTTP forgets each request once it is done. Sessions are what make a login last.
Full entry
Development🔑 Auth

JSON Web Token (JWT)

A signed token in three parts. It carries facts about a user.

A JSON Web Token is a small, signed token that carries facts about a user. It has three parts joined by dots: a header, a payload of facts and a signature. The payload might say the user's ID and when the token runs out. The server checks the signature, so it can trust the facts without looking them up. The payload is only encoded, not hidden, so it must never hold secrets.

Example
Lucy's API reads the JWT on each request. The payload says user 42, expires at 1 January 2026, and the valid signature means it can be trusted.
Why it matters
A server can check a JWT without asking a database. That helps when many servers share the work.
Full entry

In one line

Session (Web)
How a site remembers you are logged in as you move from page to page.
JSON Web Token (JWT)
A signed token in three parts. It carries facts about a user.