Home > Software engineering >  Jwt expires when user logged in from another browser
Jwt expires when user logged in from another browser

Time:03-08

I have an application that generates a JWT token for the user on logging in. But the problem is I want when loggeruser login from another device or browser he logged out from the first one. I didn't find any helpful resource. Any suggestions ?

CodePudding user response:

The only way to implement something like this is to pretty much implement a session based login flow. JWTs are stateless, so you cannot invalidate one after sending it out. You'd need to keep track of what the current given token is, which as I said, it pretty much a session based auth flow

CodePudding user response:

You need to keep track of your issued tokens in a database, then, when you are creating a new token, you simply mark the old tokens as expired (hence, the first session no longer works)

  • Related