If you need to separate front-end member login from background administrator login, You need to customize two different verification mechanisms for front-end and background login, mainly by defining different sessions. To solve this problem, you must use different cwebuser instances in the front and backend to log on. In this way, the frontend and backend logon points have been removed. However, if you exit, you will find that the frontend and backend are exited together. So I found the logout () method and found that it has a parameter $ destroysession = true. It turns out that, if you only use logout (), all sessions will be logged out, if the parameter "false" is added, the session of the currently logged-on instance will be canceled.
Yii::app()->user->logout(false);
Main. php
Front-End User (cwebuser) configuration: useridentity
'User' => array ('class' => 'webuser', // This webuser inherits the cwebuser. The Code 'statekeyprefix' => 'Member 'will be provided later ', // This is the prefix of the front-end session 'allowautologin' => true, // here it is set to allow the cookie to save the login information, while the next automatic login ),
Backend user (cwebuser) configuration: adminidentity
'Admin' => array ('class' => 'adminwebuser', // background logon class instance 'statekeyprefix' => 'admin ', // background session prefix "guestname" => "visitor "),
Yii: APP ()-> User // frontend User Information Access Method
Yii: APP ()-> admin // Method for accessing user information in the background
Yii::app()->admin->login($this->_identity,$duration);
Process frontend and backend logon in yii