I have implemented a totally different solution for this:
I maintained a database table. when a user logs in, an entry is made in the database as userId is logged in at xyz time.
now if any other user attempts to login, a query is first executed to check the logged in database. if user exists in table,
the respective error is shown ( i also maintained the machine ip)
Problems that you may face with this approach:
you are maintaining a lock (that too in persistant storage) its your eternal duty to properly release the lock at some time.
else a user wont be able to login for ever.
as far as concurrency is concerned, the database is usually the best at doing so.
Test cases you need to consider @ releasing the lock:
1. User browser close (trigger session close)
2. User browser crash / connection break (trigger session timeout)