you could almost easily do this if you integrate an existing "users online" script. basically, the safest way to do it, is query the users online, matching an ip to a username in the table, and if the ip trying to log in under a username is logged in with a different ip then disallow it.
basically you can have a table like this:
ip, username, lastaction
and when someone attempts to log in, you select the ip from that table where username = user trying to log in, if data is returned it means someone is trying to sign in, and then you want to check to see if the ip's are different.
this is to prevent a user accidentally closing a browser while they are logged in and having their session destroyed, and then trying to log back in, but they are still in the active database.
then all you have to do is deny access if the user is logged in, perhaps log the event so you can look into it.