User logout


What is the right way to log one user out by another user?

Needed for admin before delete the user.

Thank you.

One way is to store particular usr`s session id in database and destroy his session or just delete the session file when need to logout him.

Yes, session destroying is an obvious way, but I wanted to do it in more sophisticated way.

Anyway I have come to a conclusion that the better way (at least for my current project) is to delete everything by user model and then log the user out in conditional way.

For example:

public function beforeAction($action) { //in the user controller


  if((!isset(Yii::app()->user->model)) || (Yii::app()->user-isBanned)) {







I’ve configured 2 user components with success. One for the admin, one for regular users. Then as admin user i can access the frontend user component and do with it what i want (even fake-login as frontend user). See here:

setStateKeyPrefix and auto-login in Modules