From f1c92c8a67fee9d30480c6a72ac3d00b1879edfd Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 11 Feb 2018 16:15:36 -0500 Subject: 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. --- app/class/user.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') 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']); -- cgit v1.2.3