From de3a7631f81b7c69154ca56c616a6f069c90ba70 Mon Sep 17 00:00:00 2001 From: kevin olson Date: Sat, 11 Apr 2015 20:20:48 -0700 Subject: [PATCH 1/3] Cookie parsing functionality --- Http.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Http.php b/Http.php index 20b590b..0c89776 100644 --- a/Http.php +++ b/Http.php @@ -181,6 +181,29 @@ public function getHeadersFormatted ( ) { return $out; } + /** + * Get Cookies. + * + * @access public + * @return array + * @author Kevin Olson + */ + public function getCookies ( ) { + + $out = array(); + $headers = $this->getHeadersFormatted(); + + if (isset($headers['COOKIE']) && !empty($headers['COOKIE'])) { + foreach (split(';', $headers['COOKIE']) as $string) { + $kv = split('=', $string); + $out[ltrim($kv[0])] = urldecode($kv[1]); + } + } + + + return $out; + } + /** * Check if header exists. * From 438acce644354a11080087cfe78fa9a41275fda0 Mon Sep 17 00:00:00 2001 From: kevin olson Date: Sat, 11 Apr 2015 21:03:08 -0700 Subject: [PATCH 2/3] raw encode, no + in decoding cookies --- Http.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Http.php b/Http.php index 0c89776..88ebbf2 100644 --- a/Http.php +++ b/Http.php @@ -196,7 +196,7 @@ public function getCookies ( ) { if (isset($headers['COOKIE']) && !empty($headers['COOKIE'])) { foreach (split(';', $headers['COOKIE']) as $string) { $kv = split('=', $string); - $out[ltrim($kv[0])] = urldecode($kv[1]); + $out[ltrim($kv[0])] = rawurldecode($kv[1]); } } From 35c58e5cfdad9bdae0502ce6c461ddafdbcfa7c8 Mon Sep 17 00:00:00 2001 From: kevin olson Date: Tue, 21 Apr 2015 20:03:11 -0700 Subject: [PATCH 3/3] renamed getCookies to getCookieParmas to fit ServerRequestInterface.php list for psr-7 compatibility --- Http.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Http.php b/Http.php index 88ebbf2..b8a11c5 100644 --- a/Http.php +++ b/Http.php @@ -188,7 +188,7 @@ public function getHeadersFormatted ( ) { * @return array * @author Kevin Olson */ - public function getCookies ( ) { + public function getCookieParams ( ) { $out = array(); $headers = $this->getHeadersFormatted();