How to manage logins in two yii2 applications which use same database


  1. I have two backend applications which use same database. If a user logs into one application and navigate other application url in another tab it loads inner pages without login to that application. Is this possible to restrict that or is this expected functionality?

  2. I have to set who can access one application and who can access second application. Is it possible to do so? Is it possible to do with RBAC? Currently we implement permission based table set and try to check when login and navigating pages whether pages have sufficient privileges to do so.


Hi @chamath, welcome to the forum.

As for the 1st question, I hope the following wiki article will help you understand the issue.
[Guide] How to actually separate Frontend (User) and Backend (Admin) on Yii2 Advanced

The wiki talks about the complete separation of the frontend and the backend apps. I think it’s basically the same with your demand of separating 2 backend apps.

As for the 2nd question, there might be 2 approaches:

  1. Complete separated 2 apps.
  2. Shared user auth system for 2 apps and RBAC.

I don’t say which is better, it should depend on your needs.