Skip to content

Commit d68e699

Browse files
misaertnicolas-grekas
authored andcommitted
[HttpFoundation] Fix clearing CHIPS cookies
1 parent 5677bdf commit d68e699

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

ResponseHeaderBag.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,15 @@ public function getCookies(string $format = self::COOKIES_FLAT): array
234234
/**
235235
* Clears a cookie in the browser.
236236
*
237+
* @param bool $partitioned
238+
*
237239
* @return void
238240
*/
239-
public function clearCookie(string $name, ?string $path = '/', ?string $domain = null, bool $secure = false, bool $httpOnly = true, ?string $sameSite = null)
241+
public function clearCookie(string $name, ?string $path = '/', ?string $domain = null, bool $secure = false, bool $httpOnly = true, ?string $sameSite = null /* , bool $partitioned = false */)
240242
{
241-
$this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly, false, $sameSite));
243+
$partitioned = 6 < \func_num_args() ? \func_get_arg(6) : false;
244+
245+
$this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly, false, $sameSite, $partitioned));
242246
}
243247

244248
/**

Tests/ResponseHeaderBagTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ public function testClearCookieSamesite()
136136
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d M Y H:i:s T', time() - 31536001).'; Max-Age=0; path=/; secure; samesite=none', $bag);
137137
}
138138

139+
public function testClearCookiePartitioned()
140+
{
141+
$bag = new ResponseHeaderBag([]);
142+
143+
$bag->clearCookie('foo', '/', null, true, false, 'none', true);
144+
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d M Y H:i:s T', time() - 31536001).'; Max-Age=0; path=/; secure; samesite=none; partitioned', $bag);
145+
}
146+
139147
public function testReplace()
140148
{
141149
$bag = new ResponseHeaderBag([]);

0 commit comments

Comments
 (0)