Skip to content

Commit

Permalink
Update sessionStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
joanhey committed Sep 10, 2023
1 parent b602347 commit 83ab63c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/AdapterFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -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

19 changes: 19 additions & 0 deletions src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 83ab63c

Please sign in to comment.