PHP Session Check Function

,

Here is a function that returns whether or not PHP Session is activated or now.

function is_session_started()
{
    if ( php_sapi_name() !== 'cli' ) {
        if ( version_compare(phpversion(), '5.4.0', '>=') ) {
            return session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE;
        } else {
            return session_id() === '' ? FALSE : TRUE;
        }
    }
    return FALSE;
}

 

Skills

Posted on

May 19, 2016

Submit a Comment

Your email address will not be published. Required fields are marked *