How to login admin as a real user

I am wondering how to login admin under a real user, what session stuff has to be set?

Is there a plugin or so for this, or must be done manually?

You can use RBAC for manage roles.

I don’t want to complicate this. I don’t need roles.

I just want to set some session for the admin on the front-end so he looks like a regular user and should have access without presenting the login form for the admin.

The admin module already uses rights.

I would have a link for admin like:

  • View dashboard of user John.

  • View dashboard of user Jane.

and when he clicks on it, he should view them properly as he were John or Jane.

You can find this information in the Yii tutorials here.

The Blog tutorial is very helpful for starting Yii users.

I am not a Yii starter. I have already two extensions in the Yii Extensions section.

I don’t see how the tutorial will help me to login admin user as a front-end user for the selected user.

I am using something like this:

Inside controller:

$user->performAction1($object, $params);

Inside user class:

public function performAction1($object, $params)





I do not want to modify each controller.

I have thought something like:


You could try a combination of these two approaches (read full topics, to understand what it’s about)

  1. setStateKeyPrefix and auto-login in Modules

  2. Auto login after registration (fake login)

After seeing this post I wrote a wiki with exactly what you’ll need to authenticate as another user.


Thanks for the article but doesn’t seam to work with RIGHTS.

When RWebUser is set in the configuration files for handling user objects, the states are not saved.

Woil can you look into to update your Wiki?

I haven’t used the rights extension before. Duplicate whatever login code the RIGHTS extension does when you’re spoofing the user.

Please note RIGHTS extensions is very wide used. It should support vice-versa.