switchIdentity() public method
Switches to a new identity for the current user.
When $enableSession is true, this method may use session and/or cookie to store the user identity information, according to the value of $duration
. Please refer to login() for more details.
This method is mainly called by login(), logout() and loginByCookie() when the current user needs to be associated with the corresponding identity information.
public void switchIdentity ( $identity, $duration = 0 ) | ||
---|---|---|
$identity | yii\web\IdentityInterface|null |
The identity information to be associated with the current user. If null, it means switching the current user to be a guest. |
$duration | integer |
Number of seconds that the user can remain in logged-in status. This parameter is used only when |
Please login to continue.