Skip to content
Preptima
hardConceptDesignMidSeniorStaff

Would you use server-side sessions or JWTs for authenticating your API, and why?

5 min readUpdated 2026-08-15

Answer

Short answer

Default to server-side sessions in an opaque HttpOnly cookie, because revocation is a row delete and the browser cannot read the credential. Choose JWTs only when a resource server must validate without calling the issuer, keep them short-lived, and pin the algorithm, issuer, audience and expiry on every verification.

Authentication is the first boundary in this decision. Good authentication design asks how credentials are issued, revoked, rotated, inspected, and constrained after login. Weak authentication answers choose a token format before deciding what revocation and session control require. Strong authentication design starts from the threat model and then chooses the session shape that can enforce it.

Was this answer helpful?

Likely follow-ups

  • How would you implement logout-everywhere for a system that has already committed to stateless access tokens?
  • Why does refresh-token rotation with reuse detection help, and what does it cost you?
  • Where would you store the signing key, and how do you rotate it without invalidating every live token?
  • How does this design change when the token has to cross a trust boundary into a third party's service?

Related questions

Masterclass guide

Further reading