Update setcookie() for PHP8 compatibility

This commit is contained in:
Alex Cabal 2023-06-20 18:53:11 -05:00
parent 76cf0d296a
commit d4707eb595
2 changed files with 4 additions and 4 deletions

View file

@ -82,7 +82,7 @@ class Session extends PropertiesBase{
} }
public static function SetSessionCookie(string $sessionId): void{ public static function SetSessionCookie(string $sessionId): void{
setcookie('sessionid', $sessionId, time() + 60 * 60 * 24 * 14 * 1, '/', SITE_DOMAIN, true, false); // Expires in two weeks setcookie('sessionid', $sessionId, ['expires' => strtotime('+1 week'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']); // Expires in two weeks
} }
public static function Get(?string $sessionId): Session{ public static function Get(?string $sessionId): Session{

View file

@ -7,7 +7,7 @@ $hideDonationAlert = HttpInput::Bool(POST, 'hide-donation-alert');
$colorScheme = HttpInput::Str(POST, 'color-scheme'); $colorScheme = HttpInput::Str(POST, 'color-scheme');
if($hideDonationAlert !== null){ if($hideDonationAlert !== null){
setcookie('hide-donation-alert', $hideDonationAlert ? 'true' : 'false', strtotime('+1 month'), '/', '', true, true); setcookie('hide-donation-alert', $hideDonationAlert ? 'true' : 'false', ['expires' => strtotime('+1 month'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']);
} }
if($colorScheme !== null){ if($colorScheme !== null){
@ -17,10 +17,10 @@ if($colorScheme !== null){
if($colorScheme == 'auto'){ if($colorScheme == 'auto'){
// Delete the cookie; auto is the default // Delete the cookie; auto is the default
setcookie('color-scheme', '', 0, '/', '', true, true); setcookie('color-scheme', '', ['expires' => 0, 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']);
} }
else{ else{
setcookie('color-scheme', $colorScheme, strtotime('+1 year'), '/', '', true, true); setcookie('color-scheme', $colorScheme, ['expires' => strtotime('+1 year'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']);
} }
} }