[Http Foundation] Fix clear cookie samesite
This commit is contained in:
parent
e3cc3bdb04
commit
4bdea1f2e7
@ -244,10 +244,13 @@ class ResponseHeaderBag extends HeaderBag
|
|||||||
* @param string $domain
|
* @param string $domain
|
||||||
* @param bool $secure
|
* @param bool $secure
|
||||||
* @param bool $httpOnly
|
* @param bool $httpOnly
|
||||||
|
* @param string $sameSite
|
||||||
*/
|
*/
|
||||||
public function clearCookie($name, $path = '/', $domain = null, $secure = false, $httpOnly = true)
|
public function clearCookie($name, $path = '/', $domain = null, $secure = false, $httpOnly = true/*, $sameSite = null*/)
|
||||||
{
|
{
|
||||||
$this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly));
|
$sameSite = \func_num_args() > 5 ? func_get_arg(5) : null;
|
||||||
|
|
||||||
|
$this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly, false, $sameSite));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,6 +128,14 @@ class ResponseHeaderBagTest extends TestCase
|
|||||||
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; Max-Age=0; path=/; secure', $bag);
|
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; Max-Age=0; path=/; secure', $bag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testClearCookieSamesite()
|
||||||
|
{
|
||||||
|
$bag = new ResponseHeaderBag([]);
|
||||||
|
|
||||||
|
$bag->clearCookie('foo', '/', null, true, false, 'none');
|
||||||
|
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; Max-Age=0; path=/; secure; samesite=none', $bag);
|
||||||
|
}
|
||||||
|
|
||||||
public function testReplace()
|
public function testReplace()
|
||||||
{
|
{
|
||||||
$bag = new ResponseHeaderBag([]);
|
$bag = new ResponseHeaderBag([]);
|
||||||
|
Reference in New Issue
Block a user