Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Sir, i want that my account is logout when somewhen login to my acoount with different system.

What I have tried:

i am storing current user UniqueID into database and when another user login then uniqueID is change for that user and then previous login use is logout. but i this trick i have to fatch uniqueID all time when redirect the page. i want to do that without using database.
Posted
Updated 12-Mar-19 17:10pm
Comments
Richard MacCutchan 12-Mar-19 6:47am    
How will the browser be able to tell that the user is already logged in on another system?
TCS54321 12-Mar-19 6:58am    
you know my problem very well.. hope someone give solution also..
MadMyche 12-Mar-19 7:04am    
How are you storing who is logged in?
TCS54321 12-Mar-19 7:12am    
i am using a database table in which i insert login userID and one bit column to store isLogin Value in 0 and 1.
MadMyche 12-Mar-19 9:53am    
Then when User2 logs in, update the db for User1 to set IsLogin=0

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.
 
Share this answer
 
That's not how it works. It's based on session timeout, and that can only be established when the user navigates in the browser.

You could do it via a database mechanism that utilizes jobs and/or triggers, but describing that mechanism here is fairly well beyond the scope of what QA is intended for.
 
Share this answer
 
You need to manage a database to manage all login session information. If user request for logout invalidate all the session associated with that account.
 
Share this answer
 
Comments
TCS54321 12-Mar-19 6:08am    
i want to logout previous login user with same credentials when someone login with that credentials.
Mohibur Rashid 12-Mar-19 18:30pm    
Still my suggestion would work. And also look for any solution offered by any solution by your framework to track all available session by current user

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900