Tag Archives: Facebook PHP SDK

Fixing Facebook’s PHP SDK logout

If you request the “offline_access” permission when using the Facebook PHP SDK (and sometimes even without it), it makes the default logout functionality not work very well. ┬áTo fix this, here’s what worked for me:

  1. Change your logout url:
    $logoutUrl = $facebook->getLogoutUrl(array( 'next' => ($fbconfig['baseurl'].'logout.php') ));
  2. On your logout.php page, add the following code:
    setcookie('fbs_'.$facebook->getAppId(), '', time()-100, '/', 'domain.com');
    header('Location: /');

This should correctly logout your users.