Multiple device login using jwt

Issue

I am building an application and I want users to be able to log in from multiple devices without logging out of other devices.

How should I implement this functionality?

I am using Jwt token for authentication and MySQL database for storing user details

Solution

JWT is primarily use for performing stateless authentication i.e. you don’t need to perform lookup in the database for validating the token. Also, Token contain some user details which are enough for identifying the owner of the token so you don’t need to store the token in the database.

I want users to be able to log in from multiple devices without
logging out of other devices.

You can issue multiple tokens to the same user requesting from different platforms. These token will have different expiration time, so user remain log-in irrespective of the platform they would try to use and log out process will entirely depend upon the expiration time of the token.

Answered By – harry

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published