Skip to content

Commit

Permalink
Merge pull request #11121 from supermanner/fix-cookie-collection
Browse files Browse the repository at this point in the history
Fix CookieCollection::parseSetCookieHeader when the cookie has proper…
  • Loading branch information
markstory committed Aug 31, 2017
2 parents f270c98 + c023108 commit 95b0de3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Http/Cookie/CookieCollection.php
Expand Up @@ -357,7 +357,7 @@ protected static function parseSetCookieHeader($values)
continue;
}
$key = strtolower($key);
if (!strlen($cookie[$key])) {
if (array_key_exists($key, $cookie) && !strlen($cookie[$key])) {
$cookie[$key] = $value;
}
}
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Http/Cookie/CookieCollectionTest.php
Expand Up @@ -436,12 +436,13 @@ public function testCreateFromHeader()
$header = [
'http=name; HttpOnly; Secure;',
'expires=expiring; Expires=Wed, 15-Jun-2022 10:22:22; Path=/api; HttpOnly; Secure;',
'expired=expired; Expires=Wed, 15-Jun-2015 10:22:22;',
'expired=expired; version=1; Expires=Wed, 15-Jun-2015 10:22:22;',
];
$cookies = CookieCollection::createFromHeader($header);
$this->assertCount(3, $cookies);
$this->assertTrue($cookies->has('http'));
$this->assertTrue($cookies->has('expires'));
$this->assertFalse($cookies->has('version'));
$this->assertTrue($cookies->has('expired'), 'Expired cookies should be present');
}

Expand Down

0 comments on commit 95b0de3

Please sign in to comment.