From 83ab63c700f447f503258e1aa2eac5e97758deb4 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Sun, 10 Sep 2023 13:32:56 +0200 Subject: [PATCH] Update sessionStatus --- src/AdapterFunctions.php | 16 +++++++++++----- src/Session.php | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/AdapterFunctions.php b/src/AdapterFunctions.php index ae868f4..72f5783 100644 --- a/src/AdapterFunctions.php +++ b/src/AdapterFunctions.php @@ -157,14 +157,10 @@ function session_save_path(?string $path = null): string|false /** * Returns the current session status * - * @return int */ function session_status(): int { - if (Http::sessionStarted() === false) { - return PHP_SESSION_NONE; - } - return PHP_SESSION_ACTIVE; + return Http::sessionStatus(); } /** @@ -252,3 +248,13 @@ function cpu_count(): int Http::end($status); } // exit and die are language constructors, change your code with an empty ExitException */ + +/** CONSTANTS */ + +/** SESSION */ +const PHP_SESSION_DISABLED = 0; +const PHP_SESSION_NONE = 1; +const PHP_SESSION_ACTIVE = 2; + +//const SID // Not possible + diff --git a/src/Session.php b/src/Session.php index 1937b61..139c7cd 100644 --- a/src/Session.php +++ b/src/Session.php @@ -110,6 +110,25 @@ public static function sessionInit() }); } + /** + * Returns the current session status + * + * @see https://www.php.net/manual/en/function.session-status.php + */ + public static function sessionStatus(): int + { + if (static::sessionStarted()) { + if (static::$sessionFile) { + return \PHP_SESSION_ACTIVE; + } + + return \PHP_SESSION_NONE; + } + + + return \PHP_SESSION_DISABLED; + } + /** * Session create id. */