Skip to content

Commit 3e54e4a

Browse files
authored
Check and add constants for the sameSite parameter.
1 parent b78fad6 commit 3e54e4a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Symfony/Component/HttpFoundation/Cookie.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class Cookie
2828
private $raw;
2929
private $sameSite;
3030

31+
const SAMESITE_LAX = 'lax';
32+
const SAMESITE_STRICT = 'strict';
33+
3134
/**
3235
* Constructor.
3336
*
@@ -73,6 +76,11 @@ public function __construct($name, $value = null, $expire = 0, $path = '/', $dom
7376
$this->secure = (bool) $secure;
7477
$this->httpOnly = (bool) $httpOnly;
7578
$this->raw = (bool) $raw;
79+
80+
if (!in_array($sameSite, [self::SAMESITE_LAX, self::SAMESITE_STRICT, null])) {
81+
throw new \InvalidArgumentException('The sameSite parameter is not valid.');
82+
}
83+
7684
$this->sameSite = $sameSite;
7785
}
7886

0 commit comments

Comments
 (0)