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

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

Returns given session variable, or all of them, if no parameters given.
public read ( string | null $name = null ) : string | null
$name string | null The name of the session variable (or a path as sent to Hash.extract)
Результат string | null The value of the session variable, null if session not available, session not started, or provided name not found in the session.
    public function read($name = null)
    {
        if ($this->_hasSession() && !$this->started()) {
            $this->start();
        }
        if (!isset($_SESSION)) {
            return null;
        }
        if ($name === null) {
            return isset($_SESSION) ? $_SESSION : [];
        }
        return Hash::get($_SESSION, $name);
    }

Usage Example

Пример #1
4
 /**
  * {@inheritDoc}
  */
 public function redirectUrl($url = null)
 {
     if ($url === null) {
         return $this->_session->read($this->_config['redirect']);
     }
     if ($url === false) {
         $this->_session->delete($this->_config['redirect']);
         return null;
     }
     $this->_session->write($this->_config['redirect'], $url);
 }
All Usage Examples Of Cake\Network\Session::read