public static function getSessionCookieForExportUser($user, $pass) {
        global $wgServerHTTP, $wgScriptPath, $wgODBTechnicalUser;

        $user = urlencode ( $user );
        $pass = urlencode ( $pass );

        // first: request a token
        $apiPath = "/api.php?action=login&format=json&lgname=$user&lgpassword=$pass";
        $response = Http::post ( $wgServerHTTP . $wgScriptPath . $apiPath, array () );
        
        $responseObj = json_decode ( $response );
        if (isset ( $responseObj->login->result ) && $responseObj->login->result == 'NeedToken') {

            // second: re-send token and request the final sessionId
            $cookieprefix = $responseObj->login->cookieprefix;
            $sessionId = $responseObj->login->sessionid;
            $token = urlencode($responseObj->login->token);
            $response = static::post ( $wgServerHTTP . $wgScriptPath . $apiPath . "&lgtoken=$token", array (), array (
                $cookieprefix . '_session' => $sessionId
            ) );
            
            $responseObj = json_decode ( $response );

            // check if login was successful
            if (isset ( $responseObj->login->result ) && $responseObj->login->result != 'Success') {
                throw new Exception ( "Could not login user $wgODBTechnicalUser" );
            }
            $cookieprefix = $responseObj->login->cookieprefix;
            $sessionId = $responseObj->login->sessionid;
            $lguserid = $responseObj->login->lguserid;
            $lgusername = $responseObj->login->lgusername;
            
            return [
                'cookieprefix' => $cookieprefix,
                'sessionId' => $sessionId,
                'lguserid' => $lguserid,
                'lgusername' => $lgusername
            ];
        }
        throw new Exception( "Could not login user '$user'." );
    }