public static function launchCheck($needed=self::ALL, $session_object=null,$request_data=false) {
        global $TSUGI_LAUNCH, $CFG;
        $needed = self::patchNeeded($needed);

        // Check if we are an LTI 1.1 or LTI 1.3 launch
        $LTI11 = false;
        $LTI13 = false;
        $detail = LTI13::isRequestDetail($request_data);
        if ( $detail === true ) {
            $LTI13 = true;
        } else {
            $lti11_request_data = $request_data;
            if ( $lti11_request_data === false ) $lti11_request_data = self::oauth_parameters();
            $LTI11 = LTI::isRequestCheck($lti11_request_data);
            if ( is_string($LTI11) ) {
                self::abort_with_error_log($LTI11, $request_data);
            }
        }
        if ( $LTI11 === false && $LTI13 === false ) return $detail;


        $session_id = self::setupSession($needed,$session_object,$request_data);
        if ( $session_id === false ) return false;

        // Redirect back to ourselves...
        $url = self::curPageUrl();

        if ( $session_object !== null ) {
            $TSUGI_LAUNCH->redirect_url = self::curPageUrl();
            return true;
        }

        $location = U::addSession($url);
        session_write_close();  // To avoid any race conditions...

        if ( headers_sent() ) {
            echo('<p><a href="'.$url.'">Click to continue</a></p>');
        } else {
            header('Location: '.$location);
        }
        exit();
    }