lithium\storage\session\adapter\Cookie::read()
Read a value from the cookie.
Parameters
-
null|string
$key
Key of the entry to be read. If $key is null, returns all cookie key/value pairs that have been set.
-
array
$options
Options array. Not used in this adapter.
Returns
\ClosureFunction returning data in the session if successful, null
otherwise.
Source
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];
}
};
}