Add request class. Not really tested yet.
[rock.divinelegy.git] / Services / Http / Util.php
1 <?php
2
3 namespace Services\Http;
4
5 class Util
6 {
7 public static function parseCookieHeader($header)
8 {
9 $cookies = array();
10 $header = rtrim($header, "\r\n");
11 $headerPieces = preg_split('@\s*[;,]\s*@', $header);
12 foreach ($headerPieces as $c) {
13 $cParts = explode('=', $c, 2);
14 if (count($cParts) === 2) {
15 $key = urldecode($cParts[0]);
16 $value = urldecode($cParts[1]);
17 if (!isset($cookies[$key])) {
18 $cookies[$key] = $value;
19 }
20 }
21 }
22
23 return $cookies;
24 }
25 }