summaryrefslogtreecommitdiffstats
path: root/app/class/user.class.php
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2018-02-11 16:15:36 -0500
committerMalf Furious <m@lfurio.us>2018-02-11 16:15:36 -0500
commitf1c92c8a67fee9d30480c6a72ac3d00b1879edfd (patch)
treec815fbcdb0cc189704ec72916d9ef15bc0877a10 /app/class/user.class.php
parent319d38f0eb0d78d30b4261856b0abbf674535366 (diff)
downloadscrott-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.php4
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']);