The first blog established the difference between authentication and authorization. This one should answer the natural next question:
Once a user logs in successfully, how does the backend remember them when HTTP is stateless?
We'll explore how authentication evolved from passwords to session-based authentication and JWTs. I'll keep it moderately detailed, with practical examples but without getting too deep into implementation.
Imagine logging into your favourite application.
You enter your email and password, click Login, and land on your dashboard.
Now you navigate to another page, refresh the browser, or make an API request. Somehow, the application still knows that you're logged in.
But how?
The backend doesn't continuously remember every user who visits the application. In fact, HTTP itself is a stateless protocol.
Each HTTP request is independent.…