Skip to content

Commit

Permalink
fix: Fixed an issue where the samesite option defaulted to a bool
Browse files Browse the repository at this point in the history
… when it should have defaulted to the string `Lax`
  • Loading branch information
khalwat committed Feb 12, 2024
1 parent c135ced commit 9d1e9a8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/services/CookiesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function setSecure(
string $domain = '',
bool $secure = false,
bool $httpOnly = false,
bool $sameSite = false,
string $sameSite = 'Lax',
): void
{
if (empty($value)) {
Expand Down Expand Up @@ -131,8 +131,7 @@ public function getSecure(string $name = ''): string
}

if (
$cookie
&& !empty($cookie->value)
!empty($cookie->value)
&& $data !== false
) {
$result = unserialize(base64_decode($data), ['allowed_classes' => false]);
Expand Down
6 changes: 3 additions & 3 deletions src/twigextensions/CookiesTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public function getFilters(): array
public function getFunctions(): array
{
return [
new TwigFunction('setCookie', fn(string $name = "", string $value = "", int $expire = 0, string $path = "/", string $domain = "", bool $secure = false, bool $httpOnly = false, bool $sameSite = false) => $this->setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly, $sameSite)),
new TwigFunction('setCookie', fn(string $name = "", string $value = "", int $expire = 0, string $path = "/", string $domain = "", bool $secure = false, bool $httpOnly = false, string $sameSite = 'Lax') => $this->setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly, $sameSite)),
new TwigFunction('getCookie', fn($name) => $this->getCookie($name)),
new TwigFunction('setSecureCookie', fn(string $name = "", string $value = "", int $expire = 0, string $path = "/", string $domain = "", bool $secure = false, bool $httpOnly = false, bool $sameSite = false) => $this->setSecureCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly, $sameSite)),
new TwigFunction('setSecureCookie', fn(string $name = "", string $value = "", int $expire = 0, string $path = "/", string $domain = "", bool $secure = false, bool $httpOnly = false, string $sameSite = 'Lax') => $this->setSecureCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly, $sameSite)),
new TwigFunction('getSecureCookie', fn($name) => $this->getSecureCookie($name)),
];
}
Expand Down Expand Up @@ -103,7 +103,7 @@ public function setSecureCookie(
string $domain = "",
bool $secure = false,
bool $httpOnly = false,
bool $sameSite = false,
string $sameSite = 'Lax',
): void
{
Cookies::$plugin->cookies->setSecure(
Expand Down
2 changes: 1 addition & 1 deletion src/variables/CookiesVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function setSecure(
string $domain = "",
bool $secure = false,
bool $httpOnly = false,
bool $sameSite = false,
string $sameSite = 'Lax',
): void
{
Cookies::$plugin->cookies->setSecure(
Expand Down

0 comments on commit 9d1e9a8

Please sign in to comment.