Click here to Skip to main content
14,177,621 members
Rate this:
Please Sign up or sign in to vote.
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.
Updated 12-Mar-19 17:10pm
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
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190526.1 | Last Updated 12 Mar 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100