php check session code example
Example 1: php start session if not started
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
Example 2: check if session variable exists php
if (isset($_SESSION['errors']))
{
//Do stuff
}
Example 3: php check session status
session_status();
// Possible results:
// - PHP_SESSION_DISABLED = 0
// - PHP_SESSION_NONE = 1
// - PHP_SESSION_ACTIVE = 2