public static function logout_db_session($spsessionid) {
        global $CFG, $DB;

        $sessions = $DB->get_records_sql(
            'SELECT userid, sessdata FROM {sessions} WHERE timemodified > ?',
            array(time() - $CFG->sessiontimeout)
        );

        foreach ($sessions as $session) {
            // Get user session from DB.
            if (session_decode(base64_decode($session->sessdata))) {
                if (isset($_SESSION['SESSION']) && isset($_SESSION['SESSION']->shibboleth_session_id)) {
                    // If there is a match, kill the session.
                    if ($_SESSION['SESSION']->shibboleth_session_id == trim($spsessionid)) {
                        // Delete this user's sessions.
                        \core\session\manager::kill_user_sessions($session->userid);
                    }
                }
            }
        }
    }