lithium\storage\session\adapter\Cookie::read PHP Метод

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

Read a value from the cookie.
public read ( null | string $key = null, array $options = [] ) : Closure
$key null | string Key of the entry to be read. If $key is null, returns all cookie key/value pairs that have been set.
$options array Options array. Not used in this adapter.
Результат Closure Function returning data in the session if successful, `null` otherwise.
    public function read($key = null, array $options = array())
    {
        $config = $this->_config;
        return function ($self, $params) use(&$config) {
            $key = $params['key'];
            if (!$key) {
                if (isset($_COOKIE[$config['name']])) {
                    return $_COOKIE[$config['name']];
                }
                return array();
            }
            if (strpos($key, '.') !== false) {
                $key = explode('.', $key);
                $result = isset($_COOKIE[$config['name']]) ? $_COOKIE[$config['name']] : array();
                foreach ($key as $k) {
                    if (!isset($result[$k])) {
                        return null;
                    }
                    $result = $result[$k];
                }
                return $result;
            }
            if (isset($_COOKIE[$config['name']][$key])) {
                return $_COOKIE[$config['name']][$key];
            }
        };
    }