bilalrcc says:
Its pretty easy you need to implement this in your login method
1. take user name & password and check if authentication is already true for any user
2. .Then match username and the current supplied username if not same then raise message Please logout and try login
3. If same user tries login twice just redirect to the default pge.
Unless and until user logs out and other user can't login.
You need to check if already one user loggedin then redirect user to home page where user logout from the application and redirect to login page.
All these functionality implemented in the below article.
Please refer the article.