aboutsummaryrefslogtreecommitdiff
path: root/Psso/Session.php
diff options
context:
space:
mode:
authorwinter Sparkles2026-08-09 15:44:18 +0100
committerwinter Sparkles2026-08-09 15:44:18 +0100
commit96387025da63025894f6259f7eebed0fc6fc53ac (patch)
treea83d73eeb7ec419b24ff78291634503d4ebceec1 /Psso/Session.php
parentc8998ccdff070d7c73a634e031a041260b87c3b1 (diff)
implement the rest of login process incl. cookie redirects and 'next'
Diffstat (limited to 'Psso/Session.php')
-rw-r--r--Psso/Session.php14
1 files changed, 11 insertions, 3 deletions
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()