note 123337 rejected from function.session-status by cmb

From: Date: Tue, 13 Nov 2018 09:51:56 +0000
Subject: note 123337 rejected from function.session-status by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-209688@lists.php.net to get a copy of this message
Note Submitter: solinar at web dot de ---- Be careful when using session_status()-values and constants in an if-condition. My environment: - CentOS 7, - Apache2 (httpd) - PHP 7.2.12 My code was : if(session_status() === PHP_SESSION_NONE){ session_start(); } While debugging with xDebug, it went into the true-block while session_status() returned 2 (PHP_SESSION_NONE equals 1). Storing the return value into a variable and comparing against PHP_SESSION_NONE showed the same issue. After storing PHP_SESSION_NONE into another variable and comparing both variables, the issue got solved. I have no idea why the original comparision returned false-positive. So, im my case this was the solution: $session_status = session_status(); $session_none = PHP_SESSION_NONE; if($session_none === $session_status) { session_start(); }

« previous php.notes (#209688) next »