check session in php code example
Example 1: check session php
// For PHP versions > 5.4.0
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
// For PHP Versions < 5.4.0
if(session_id() == '') {
session_start();
}
Example 2: php check session status
session_status();
// Possible results:
// - PHP_SESSION_DISABLED = 0
// - PHP_SESSION_NONE = 1
// - PHP_SESSION_ACTIVE = 2