Cake\Network\Session::check PHP Метод

check() публичный Метод

Returns true if given variable name is set in session.
public check ( string | null $name = null ) : boolean
$name string | null Variable name to check for
Результат boolean True if variable is there
    public function check($name = null)
    {
        if ($this->_hasSession() && !$this->started()) {
            $this->start();
        }
        if (!isset($_SESSION)) {
            return false;
        }
        return Hash::get($_SESSION, $name) !== null;
    }

Usage Example

Пример #1
2
 /**
  * Get the current user.
  *
  * Will prefer the static user cache over sessions. The static user
  * cache is primarily used for stateless authentication. For stateful authentication,
  * cookies + sessions will be used.
  *
  * @param string $key field to retrieve. Leave null to get entire User record
  * @return mixed User record. or null if no user is logged in.
  * @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user
  */
 public static function user($key = null)
 {
     if (!empty(static::$_user)) {
         $user = static::$_user;
     } elseif (static::$sessionKey && Session::check(static::$sessionKey)) {
         $user = Session::read(static::$sessionKey);
     } else {
         return null;
     }
     if ($key === null) {
         return $user;
     }
     return Hash::get($user, $key);
 }
All Usage Examples Of Cake\Network\Session::check