Skip to content

Commit eec2141

Browse files
[HttpFoundation] Fix dumping array cookies
1 parent 1120e76 commit eec2141

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Request.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,10 @@ public function __toString()
522522
$cookies = [];
523523

524524
foreach ($this->cookies as $k => $v) {
525-
$cookies[] = $k.'='.$v;
525+
$cookies[] = \is_array($v) ? http_build_query([$k => $v], '', '; ', \PHP_QUERY_RFC3986) : "$k=$v";
526526
}
527527

528-
if (!empty($cookies)) {
528+
if ($cookies) {
529529
$cookieHeader = 'Cookie: '.implode('; ', $cookies)."\r\n";
530530
}
531531

Tests/RequestTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,12 @@ public function testToString()
17021702
$asString = (string) $request;
17031703

17041704
$this->assertStringContainsString('Cookie: Foo=Bar; Another=Cookie', $asString);
1705+
1706+
$request->cookies->set('foo.bar', [1, 2]);
1707+
1708+
$asString = (string) $request;
1709+
1710+
$this->assertStringContainsString('foo.bar%5B0%5D=1; foo.bar%5B1%5D=2', $asString);
17051711
}
17061712

17071713
public function testIsMethod()

0 commit comments

Comments
 (0)