Skip to content
Permalink
Browse files

Fix cookies sending by ResponseEmitter.

  • Loading branch information...
ADmad committed Jan 1, 2017
1 parent 74015d6 commit 4efbfcda4c16f939460bc2bcf9d19e033f810454
Showing with 22 additions and 2 deletions.
  1. +22 −2 src/Http/ResponseEmitter.php
@@ -162,9 +162,14 @@ protected function emitStatusLine(ResponseInterface $response)
*/
protected function emitHeaders(ResponseInterface $response)
{
$cookies = [];
if (method_exists($response, 'cookie')) {
$cookies = $response->cookie();
}
foreach ($response->getHeaders() as $name => $values) {
if (strtolower($name) === 'set-cookie') {
$this->emitCookies($values);
$cookies = array_merge($cookies, $values);
continue;
}
$first = true;
@@ -177,6 +182,8 @@ protected function emitHeaders(ResponseInterface $response)
$first = false;
}
}
$this->emitCookies($cookies);
}
/**
@@ -187,7 +194,20 @@ protected function emitHeaders(ResponseInterface $response)
*/
protected function emitCookies(array $cookies)
{
foreach ((array)$cookies as $cookie) {
foreach ($cookies as $cookie) {
if (is_array($cookie)) {
setcookie(
$cookie['name'],
$cookie['value'],
$cookie['expire'],
$cookie['path'],
$cookie['domain'],
$cookie['secure'],
$cookie['httpOnly']
);
continue;
}
if (strpos($cookie, '";"') !== false) {
$cookie = str_replace('";"', "{__cookie_replace__}", $cookie);
$parts = str_replace("{__cookie_replace__}", '";"', explode(';', $cookie));

0 comments on commit 4efbfcd

Please sign in to comment.
You can’t perform that action at this time.