Hi Mohammad,
Source- https://www.codeproject.com/Questions/1279638/How-to-logout-my-account-when-login-with-same-acco
you can do this by using cookies.
When a user access your website using a new browser (Device A), creates a random string (as Session Token A) and stores at the user's browser's cookies with the expire date set to 180 days.
Store the random string (session token A) together with the user id in database.
Condition 1:
If the user access your website using the same browser (Device A), the same session token (Session Token A) will be sent to the server to verify that it is the same user.
Condition 2:
If the user access your website using another device (Device B), new session token (Session Token B) will be created. Delete "Session Token A" from database, so when next time the user re-access the website on old device (Device A), "Session Token A" will not able to be verified as it is already not existed in database. Therefore, user will longer able to access your website from Device A.
Hope this will help you.
Regards
Rahul