diff options
author | Malf Furious <m@lfurio.us> | 2018-02-11 16:15:36 -0500 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2018-02-11 16:15:36 -0500 |
commit | f1c92c8a67fee9d30480c6a72ac3d00b1879edfd (patch) | |
tree | c815fbcdb0cc189704ec72916d9ef15bc0877a10 /app/class/user.class.php | |
parent | 319d38f0eb0d78d30b4261856b0abbf674535366 (diff) | |
download | scrott-f1c92c8a67fee9d30480c6a72ac3d00b1879edfd.tar.gz scrott-f1c92c8a67fee9d30480c6a72ac3d00b1879edfd.zip |
Address issue with user functions getCurrent() and setCurrent()
Previously, these functions would always call session_start() before
doing most of their work. However, I've found that calling that
function two or more times within the lifetime of a program results in
NOTICE messages output from the PHP interpreter. Therefore, I am now
only calling session_start() if the session is not already active.
Diffstat (limited to 'app/class/user.class.php')
-rw-r--r-- | app/class/user.class.php | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/class/user.class.php b/app/class/user.class.php index 6f05570..50679ee 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -131,7 +131,7 @@ class user extends agent */ public static function getCurrent() : ?user { - if (!session_start()) + if ((session_status() != PHP_SESSION_ACTIVE) && !session_start()) throw new Exception("Unable to aquire a PHP session"); if (!isset($_SESSION['userguid'])) @@ -168,7 +168,7 @@ class user extends agent */ public static function setCurrent(?user $user = NULL) : void { - if (!session_start()) + if ((session_status() != PHP_SESSION_ACTIVE) && !session_start()) throw new Exception("Unable to aquire a PHP session"); unset($_SESSION['userguid']); |