diff --git a/lib/HttpInput.php b/lib/HttpInput.php index 7e360b52..d4347a30 100644 --- a/lib/HttpInput.php +++ b/lib/HttpInput.php @@ -188,7 +188,7 @@ class HttpInput{ try{ return intval($var); } - catch(Exception){ + catch(\Exception){ return null; } } @@ -205,7 +205,7 @@ class HttpInput{ try{ return floatval($var); } - catch(Exception){ + catch(\Exception){ return null; } } @@ -215,8 +215,7 @@ class HttpInput{ try{ return new DateTimeImmutable($var); } - catch(Exception){ - vdd('q'); + catch(\Exception){ return null; } } diff --git a/lib/Session.php b/lib/Session.php index b11a4d94..d954ade9 100644 --- a/lib/Session.php +++ b/lib/Session.php @@ -2,8 +2,6 @@ use Ramsey\Uuid\Uuid; use Safe\DateTimeImmutable; -use function Safe\strtotime; - /** * @property User $User * @property string $Url @@ -100,7 +98,7 @@ class Session{ } public static function SetSessionCookie(string $sessionId): void{ - setcookie('sessionid', $sessionId, ['expires' => strtotime('+1 week'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']); // Expires in two weeks + setcookie('sessionid', $sessionId, ['expires' => (new DateTimeImmutable('+1 week'))->format('@'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']); // Expires in two weeks } /** diff --git a/www/ebooks/download.php b/www/ebooks/download.php index 49907a17..8ba94fd8 100644 --- a/www/ebooks/download.php +++ b/www/ebooks/download.php @@ -1,6 +1,5 @@ strtotime('+2 week'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']); + setcookie('download-count', (string)$downloadCount, ['expires' => (new DateTimeImmutable('+2 week'))->format('@'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']); } catch(Exceptions\InvalidFileException | Exceptions\EbookNotFoundException){ Template::Emit404(); diff --git a/www/settings/post.php b/www/settings/post.php index 0f90cce1..842a80da 100644 --- a/www/settings/post.php +++ b/www/settings/post.php @@ -1,11 +1,9 @@ strtotime('+1 month'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']); + setcookie('hide-donation-alert', $hideDonationAlert ? 'true' : 'false', ['expires' => (new DateTimeImmutable('+1 month'))->format('@'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']); } if($colorScheme !== null){ @@ -18,7 +16,7 @@ if($colorScheme !== null){ setcookie('color-scheme', '', ['expires' => 0, 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']); } else{ - setcookie('color-scheme', $colorScheme, ['expires' => strtotime('+1 year'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']); + setcookie('color-scheme', $colorScheme, ['expires' => (new DateTimeImmutable('+1 year'))->format('@'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']); } }