web\User switchIdentity()

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 $identity is not null.

doc_Yii
2016-10-30 17:17:26
Comments
Leave a Comment

Please login to continue.