prevent all other user log in with the same user account, I tried the following

  authentication, codeigniter, javascript, php

first tried
i create a login status field in table and by default it will be 0 and when user log in it will update to 1. so when other tried to login with the same account can not logged in.
but the problem is when i update the login status when user click to the logout button but when internet connect goes out or pc is shutdown or user close the browser without clicking the logout button then the login status could not be updated and always shows ‘some one already logged in’.

second tried
I generate a login token at the time of login and store it the database and session also. On every event I check that database token with the session if true then let them process. and when other user login with the same account then the token is update and the previous user log out due to session did not match with the database

but i want that other user can not be logged in while one user is already logged in.
because I am creating the online exam portal so in this the first one is not work when user’s browser is closed directly or system shutdown and the second one allow the other user to log in and logout the previous user

is there any way to prevent other user can not be logged in while one is log in

Source: Ask PHP

LEAVE A COMMENT