On modern GNU/Linux systems, pam_limits can limit the number of sessions per user.
In order to limit the number of sessions per user, you can add entries to a file in /etc/limits.d/ (say /etc/limits.d/maxlogins.conf)
# Some of the lines in this sample might conflict and overwrite each other
# The whole range is included to illustrate the possibilities
#limit users in the users group to two logins each
@users       -       maxlogins     2
#limit all users to three logins each
*            -       maxlogins     3
#limit all users except root to 20 simultaneous logins in total
*            -       maxsyslogins     20
#limit in the users group to 5 logins in total
%users       -       maxlogins     2
#limit all users with a GID >= 1000 to two logins each
1000:        -       maxlogins     2
#limit user johndoe to one login
johndoe      -       maxlogins     2
Other Unix-like OSes and systems without the pam_limits module would differ.