How to allow user login only once at a time?
You can get what you're looking for with a combination of existing modules:


Session limit module
Password policy module
User stats module + Views module


You shouldn't have to write a single bit of code using those 3 modules.

You don't mention which version of Drupal you're using but each of those modules have D6 and D7 releases (albeit a dev release for one of them).