Example #1
0
function common_ensure_session()
{
    $c = null;
    if (array_key_exists(session_name(), $_COOKIE)) {
        $c = $_COOKIE[session_name()];
    }
    if (!common_have_session()) {
        if (common_config('sessions', 'handle')) {
            Session::setSaveHandler();
        }
        if (array_key_exists(session_name(), $_GET)) {
            $id = $_GET[session_name()];
        } else {
            if (array_key_exists(session_name(), $_COOKIE)) {
                $id = $_COOKIE[session_name()];
            }
        }
        if (isset($id)) {
            session_id($id);
        }
        @session_start();
        if (!isset($_SESSION['started'])) {
            $_SESSION['started'] = time();
            if (!empty($id)) {
                common_log(LOG_WARNING, 'Session cookie "' . $_COOKIE[session_name()] . '" ' . ' is set but started value is null');
            }
        }
    }
}