I've been reading up on this topic a lot but could not find a good answer that I was looking for.
So my understanding of the pros and cons of JWT vs Session is
JWT pro
- more scalable since no DB look up on server side. (assuming stateless JWT)
con
- storage of token on client side needs to be well thought out. (cookie w/ httpOnly is preferable over local storage but cookie has 4kb size limit)
- not immediately revocable
- permissions can go stale until the next refresh
Session pro
- arguably more secure since you are only passing around session id (opaque ref), easier to protect against CSRF than XSS, etc.
- changes on user are reflected immediately.
con
- less scalable than token
So given my understanding,
which approach does website that supports huge number of users (amazon, uber) use? Is using session w/ distributed cache good enough?
what is the real life use case where it makes more sense to use JWT (token based) over session based?
Thank you!