Why JWT?
JWT: The digital security guard. Let’s explore its importance in authentication.
What is actually JWT (JSON Web Token)?
It is just a token that is generated by the server and sent to the client to be stored upon successful authentication (login) and then sent back from the client to the server within each request.
Get Hisham Elmorsi’s stories in your inbox
Join Medium for free to get updates from this writer.
They may be stored as cookies that get sent automatically by the browser within each request to the same website you received the JWT from.
But why do we need it and how would it be without JWT or server session (another authentication method)?
http requests are stateless, that means: each request doesn’t know anything about other requests or the history of the requests before. So (without those authentication methods mentioned before like JWT), if you logged in successfully, and needed to send another request to another protected route, as the two http requests don’t know anything about each other you will have to login again and that will work fine. But now, anything you want to do in the website, you will have to enter your credentials again to login! it would be a nightmare, isn’t it?
ex: You were logged to an e-commerce website, browsing items to purchase. Each time you try to purchase items, or do anything related to you, you will be prompted to login again That won’t only disturbs your shopping experience but consumes time too.
Continued…







