yii\web\User::getIdentity PHP Method

getIdentity() public method

When [[enableSession]] is true, this method may attempt to read the user's authentication data stored in session and reconstruct the corresponding identity object, if it has not done so before.
See also: login()
See also: logout()
public getIdentity ( boolean $autoRenew = true ) : yii\web\IdentityInterface | null
$autoRenew boolean whether to automatically renew authentication status if it has not been done so before. This is only useful when [[enableSession]] is true.
return yii\web\IdentityInterface | null the identity object associated with the currently logged-in user. `null` is returned if the user is not logged in (not authenticated).
    public function getIdentity($autoRenew = true)
    {
        if ($this->_identity === false) {
            if ($this->enableSession && $autoRenew) {
                $this->_identity = null;
                $this->renewAuthStatus();
            } else {
                return null;
            }
        }
        return $this->_identity;
    }

Usage Example

 public function getIdentity($autoRenew = true)
 {
     if ($this->_overrideIdentity !== null) {
         return $this->_overrideIdentity;
     }
     return parent::getIdentity($autoRenew);
 }
All Usage Examples Of yii\web\User::getIdentity