From 96387025da63025894f6259f7eebed0fc6fc53ac Mon Sep 17 00:00:00 2001 From: winter Sparkles Date: Sun, 9 Aug 2026 15:44:18 +0100 Subject: implement the rest of login process incl. cookie redirects and 'next' --- Psso/Session.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'Psso/Session.php') diff --git a/Psso/Session.php b/Psso/Session.php index 34dd94a..9893096 100644 --- a/Psso/Session.php +++ b/Psso/Session.php @@ -7,7 +7,7 @@ class Session { protected static ?array $config = null; protected \PDO $db; - private ?string $token = null; + public protected(set) ?string $token = null; public static function setDsn( array $config, @@ -34,6 +34,14 @@ class Session { return self::$instance; } + public static function override(string $newToken): void { + if (!isset(self::$instance)) { + self::$instance = new self(); + } + self::$instance->token = $newToken; + self::$instance->setCookie(true); + } + protected function setup(): void { $this->db->exec( <<<'END' @@ -50,8 +58,8 @@ class Session { return explode('.', $_SERVER['HTTP_HOST'], 2)[1]; } - protected function setCookie(): void { - if (isset($_COOKIE['PSSO_session'])) return; + protected function setCookie(bool $force = false): void { + if (isset($_COOKIE['PSSO_session']) && !$force) return; header( 'Set-Cookie: PSSO_session=' . $this->currentToken() . '; Domain=' . $this->domain() -- cgit v1.3