yii\web\User::getId PHP Method

getId() public method

Returns a value that uniquely represents the user.
See also: getIdentity()
public getId ( ) : string | integer
return string | integer the unique identifier for the user. If `null`, it means the user is a guest.
    public function getId()
    {
        $identity = $this->getIdentity();
        return $identity !== null ? $identity->getId() : null;
    }

Usage Example

Example #1
0
 /**
  * @param string $default
  *
  * @return string
  */
 protected function getIdentifier($default)
 {
     $id = $default;
     if ($this->user instanceof User && !$this->user->getIsGuest()) {
         $id = $this->user->getId();
     }
     return $id;
 }
All Usage Examples Of yii\web\User::getId