How do you logout a user from the server in PHP?

I want to create a customisation that logs users out after a certain time of inactivity since closing Sugar in their browser (e.g. log out at night). I need this separate from Oauth token lifetimes so that APIs and the Outlook Plugin can still be configured to never log off.

I'm trying to find a way to log the current user out in Sugar using PHP. I've looked at these files and tried their logout implementations with appropriate adjustments in a custom logic hook and a custom entry point, but none have worked:

  • clients/base/api/OAuth2Api.php
  • modules/Users/Logout.php

Do you know of any method of logging out a user without using the browser?

Parents Reply
  • Hi Artis Plocins

    Deleting entries from the oauth_tokens table will not just cause the regeneration of the next token to fail as soon as the current one expires.

    It will also logout the users, however not right away, but within 2 min: The oauth_tokens table is checked every 2 mins if the refresh token still exists. If not, the access token is set to NULL and the session is logged out.

    See include/SugarOAuth2/SugarOAuth2Storage.php

    ...

    const TOKEN_CHECK_TIME = 120;

    ...

    public function getAccessToken($oauth_token)

Children
No Data