I want to prevent multiple logins in a php application.
First, I create login status (active, notactive) in a user table.
When user A logs in the user status
You need to create a unique ID and store that in a database. What I did was create too. I store one in a session variable and use that to prevent session hijacking and another in a database to prevent multiple logins. The following code will create a unique ID:
$unique_id = sha1('xzr4'.gethostbyaddr($_SERVER['REMOTE_ADDR']).$random_string.$_SERVER['HTTP_USER_AGENT'].'f8k2');
If the unique ID doesn't match, you simply log the user out.