← Retour au blog
tech 17 June 2026

Stop Using JWTs for Authentication

JSON Web Tokens (JWTs) are often mistakenly used for user authentication. Discover why this is a bad idea and which alternatives to prefer.

Article inspired by the original source
Stop Using JWTs ↗ gist.github.com

Introduction

JSON Web Tokens (JWTs) have become a popular tool for user authentication in modern web applications. However, this popularity is often misplaced. JWTs are not designed to manage user sessions securely in the long term. So why do so many companies continue to use them? And what are the alternatives?

The Limitations of JWTs

JWTs are primarily designed for very specific use cases, particularly the secure exchange of information between two parties. However, using JWTs to maintain a user session is problematic for several reasons:

  1. Limited lifespan: JWTs are designed for very short lifespans, typically less than 5 minutes. User sessions, on the other hand, often require longer durations.
  2. Complexity of state management: JWTs are often used for "stateless" authentication. However, securely managing sessions always requires some degree of "state".
  3. Security: Storing JWTs in localStorage or sessionStorage exposes the application to XSS (Cross-Site Scripting) attacks.

Safer Alternatives

Fortunately, more suitable solutions exist for managing user sessions:

  • Session cookies: Session cookies are securely stored on the server and offer built-in protection against CSRF attacks.
  • PASETO (Platform-Agnostic Security Tokens): Unlike JWTs, PASETO is designed with enhanced security in mind and avoids common configuration errors.

Use Case

Consider the example of a tech company that migrated from JWTs to session cookies. Not only did the application's security improve, but session management became simpler and more efficient. Developers reported a decrease in authentication-related security incidents.

Conclusion

It's time to reconsider the use of JWTs for user authentication. Alternatives like session cookies and PASETO offer increased security and simplicity. Don't get caught up in the misplaced popularity of JWTs, and explore other options for better session management.

Let's discuss your project in 15 minutes.

JWT authentication session management security PASETO
Deepthix newsletter · 100% AI · every Monday 8am

An AI agent reads tech for you.

Our AI agent scans ~200 sources per week and ships the best articles to your inbox Monday 8am. Free. One click to unsubscribe.

Visit the newsletter page →

Want to automate your operations?

Let's talk about your project in 15 minutes.

Book a call