PHP / Programmings

Facebook PHP SDK Logout Issue Solved

When working with Facebook login integration using facebook-php SDK, the really annoying thing is the issue with logout. The logout method used in the example file, included with sdk download package, is redirecting us to a facebook logout url. But it doesn’t logout, since session variables still remains there.

This is the method used in the example file with SDK

$logoutUrl = $facebook->getLogoutUrl();
<a href="<?php echo $logoutUrl; ?>">Logout</a>

This doesn’t destroy sessions stored in browser.And this method didn’t work for me.

I modified the logout link as

<a href="?logout=true">Logout</a>

And the php code as

	$logoutUrl = $facebook->getLogoutUrl(array('next'=>$redir_url));

This really works for me. If you also face this problem this may help you.


9 thoughts on “Facebook PHP SDK Logout Issue Solved

  1. you can put php code on same php file or separate php file or in controller if you follow MVC structure. This is code is part of a php sdk which have logout issue. this is not full code. you can find full code on facebook developer site. please see this link.
    You can download SDK from GitHub

    refer javascript sdk too.. That might be easier..
    Hope this will help.. 🙂

  2. just 1 small thing for the other guys:

    We use this:

    <a href=”?logout=true” rel=”nofollow” > Logout </a>

    instead of this:

    <a href=”?logout=yes” rel=”nofollow” > Logout </a>

    Small thing, but cause headaches 🙂

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s