diff --git a/src/services/CookiesService.php b/src/services/CookiesService.php index 1f75906..f5f1678 100644 --- a/src/services/CookiesService.php +++ b/src/services/CookiesService.php @@ -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)) { @@ -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]); diff --git a/src/twigextensions/CookiesTwigExtension.php b/src/twigextensions/CookiesTwigExtension.php index 1b252e1..10bc372 100644 --- a/src/twigextensions/CookiesTwigExtension.php +++ b/src/twigextensions/CookiesTwigExtension.php @@ -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)), ]; } @@ -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( diff --git a/src/variables/CookiesVariable.php b/src/variables/CookiesVariable.php index 3d1c737..0309e75 100755 --- a/src/variables/CookiesVariable.php +++ b/src/variables/CookiesVariable.php @@ -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(