How to limit number of active logins per user?

In my Yii2 application I want to limit the number of active logins each user can have.

Is there any plugin or option to enable the same in Yii2?

You don’t need any plugin, you can implement this easily. In your user table put a field called sessionId which is unique id of the session. When a user loggs in, then a new sessionId is generated and saved in DB and cookie. Let’s say it is a value ‘A’. During every action, you check weather the value A from a cookie is equal to value in a DB. If it is, then user is allowed to perform an action, and if not then logout a user and show him Login page.

Please note that value in DB will change from A to B when user loggs in from another device (moble, other computer, tablet)