Is it possible to call logout.php programatically?

(5 posts) (2 voices)
  1. mirekh, Member

    I have an application which integrates with MyDBR on apache server. The thing is, that I want to logout from my application together with logging out from MyDBR. So I've prepared the following piece of code (in angular):
    public callMyDbrLogoutUrl(path: string): any { let xmlHttp = null;

    xmlHttp = new XMLHttpRequest(); 'GET', '', false, ); xmlHttp.onerror = function() { return null; }; xmlHttp.send(); return xmlHttp.responseText; }
    The function is called when the button 'Logout' on the app is pressed. I've tried to run the application together with MyDBR app on test environment. Unfortunately, after clicking logout button user wasn't logged out from MyDBR even if I observed on the developer tools that url '' was called. So that's why I am asking, is it possible to call logout.php programatically and if yes, than what I am missing?

  2. myDBR Team, Key Master

    Making the user's browser to call the logout.php, will log the user out. Your code should work as expexted if you follow the Cross-Origin Request requirements. As you are doing it via Ajax, any screen user might have open is unaffacted.

    There are actually multiple ways of logging user out. What is the login method that you are using (myDBR login, SSO, else)? The easiest way is to redirect user's browser to the logout page (you can define the page user is redirected after the logout).

    myDBR Team

  3. mirekh, Member

    Yes, the login method is SSO.
    Redirecting user's browser to the logout page works, but I want to execute extra piece of code after the redirection, so that's why I am using httpClient instead of it. I execute my callMyDbrLogoutUrl method in a following way:
    const path = organisation.concat('/logout.php'); try { const response = await this.authenticationService.callMyDbrLogoutUrl( path, ); await this.logInfoFromMyDbrUrlResponse(response); // log info to console } catch (error) { await this.logErrorFromMyDbrUrlResponse(error); //log error to console }
    Today I checked how it works (in developer tools) and I have observed that const response after method call is undefined. The http method 'logout.php' is called but no more data I have observed in developer tools (http headers, response, etc.) :/.

  4. mirekh, Member

    myDBR Team, you've mentioned that there are multiple ways of logging user out. Are there any other ways than my proposition for SSO login?

  5. myDBR Team, Key Master

    The easiest way of executing extra code after the user is redirected to myDBR logout URL is to define what myDBR should do after the logout. The default behavior is to redirect to the thankyou.html-page when you use SSO (without SSO user is redirected to the login page). This is defined in '$mydbr_defaults['logout']['url']' variable that you can override in

    . You can redirect the user back to your application.

    If you want to have user specific URL where user is redirected after the logout is done, you can define an SSO automatic parameter logout_url_redirect. myDBR will then use the value of this when redirecting.

    As for the Ajax call to logout, it will log user out from myDBR (assuming you comply with the Cross-Origin Request requirements). You can try loggin into myDBR demo and pasting following to developer console. You will notice that the xmlHttp.responseText will return the login page HTML.

    xmlHttp = new XMLHttpRequest(); 'GET', '', false );
    myDBR Team


You must log in to post.