check if session is enabled php code example
Example 1: php check if session is running
<?php
if(session_status() == PHP_SESSION_ACTIVE){
//a session is already running
session_destroy(); //stops the session
}
?>
Example 2: 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();
}