14 'max_age' =>
'Max-Age',
15 'expires' =>
'Expires',
16 'version' =>
'Version',
19 'discard' =>
'Discard',
20 'comment' =>
'Comment',
21 'comment_url' =>
'Comment-Url',
22 'http_only' =>
'HttpOnly'
25 public function parseCookie($cookie, $host =
null, $path =
null, $decode =
false)
28 $pieces = array_filter(array_map(
'trim', explode(
';', $cookie)));
31 if (empty($pieces) || !strpos($pieces[0],
'=')) {
36 $data = array_merge(array_fill_keys(array_keys(self::$cookieParts),
null), array(
47 foreach ($pieces as $part) {
59 $value = urldecode($value);
64 if (!empty($data[
'cookies'])) {
65 foreach (self::$cookieParts as $mapValue => $search) {
66 if (!strcasecmp($search, $key)) {
67 $data[$mapValue] = $mapValue ==
'port' ? array_map(
'trim', explode(
',', $value)) : $value;
76 $data[$foundNonCookies ?
'data' :
'cookies'][$key] = $value;
80 if (!$data[
'expires'] && $data[
'max_age']) {
81 $data[
'expires'] = time() + (int) $data[
'max_age'];
90 if (!$data[
'path'] || substr($data[
'path'], 0, 1) !==
'/') {
111 if (empty($path) || substr($path, 0, 1) !==
'/') {
121 $rightSlashPos = strrpos($path,
'/');
122 if ($rightSlashPos === 0) {
128 return substr($path, 0, $rightSlashPos);