You can just add a column in users table (is_online). When user log in, set to true. On log out, set to false. You need work with sessions too. Save the user session to validate.
if ( user.is_online ){
if ( user.session_id == this.session.id )
//OK, same user log in.
else
//OPS, different sessions, other user log in.
}
else {
//user log in first time
}
Sorry for the poor code, I don't code in php, but this verification must be server side.
@ UPDATE
If user left the website, without log out, you need add one more validation. Check if session status is active. If not, left is_online true and change session to new session. Learn more in session_status().
Maybe, you need run some cron to destroy inactive sessions. I don't know if this is the best option.