Hi,
This is Aayush Sinha, a Web Developer with 4+ years of Expertise in PHP, Database Management...
My way of solving this would be sending a ping from the client browser to the server every 1 minute and updating the database telling it that the user is logged in, and if there is no ping even after one minute, this means the user is logged out, and while the user is logged in and someone else tries to log in using the same credentials on any other machine, then don't log in...
Please message me if you have any doubts regarding this