How to prevent simultaneous login with same user on different pcs
USING SP FOR AUTHENTICATE ,SESSION LOG OUT
How to prevent simultaneous login with same user on different pcs
USING SP FOR AUTHENTICATE ,SESSION LOG OUT
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sandeep KumarPosted Apr 19, 2023, 7:06 AM
is this sp for user authenticate, then where password parameter
Amit MohantyPosted Apr 18, 2023, 7:31 AM
Create a session table in your database that stores the user ID, session ID, and login time. When a user logs in, generate a unique session ID and store it in the session table along with the user ID and login time. Create a stored procedure that checks the session table for the existence of a session ID associated with the user ID. If the stored procedure finds a session ID, it can either log out the user from the previous session or prevent the new login attempt. When the user logs out, delete the session ID from the session table.
Here is a sample code for the stored procedure:
You can call this stored procedure when the user logs in and pass the user ID and session ID as parameters. The stored procedure will check if the user has an active session and log them out from the previous session if necessary. If the user doesn't have an active session, the stored procedure will insert a new session record.
To log out the user, you can either redirect them to a logout page or simply delete the session record from the session table. Here is a sample code to delete the session record:
You can call this code when the user logs out or when their session expires.