Reputation: 4078
I am using facebook-php-sdk
(github) for facebook login on my localhost page, when i logout, the page is not redirecting..
And the same page i can see the my profile information in arrays, even after i pressed logout then data should be empty on page but its display all information.
i have used below code, but its not redirect
$logoutUrl = $facebook->getLogoutUrl(array('next' => 'http://google.com'));
<?php if ($user): ?>
<a href="<?php echo $logoutUrl; ?>">Logout</a>
<?php else: ?>
<div>
Login using OAuth 2.0 handled by the PHP SDK:
<a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
</div>
<?php endif ?>
Upvotes: 0
Views: 1553
Reputation: 76870
The only way to have a succesful logaut using the PHP SDK was this for me: redirect the logout button to a function and do the following
private function do_facebook_logout() {
// Get an instance of the Facebook class
$facebook = $this->facebook_instance_factory();
// Destroy the session so that no Facebook data is held
$facebook->destroySession();
// Get the logout URL from the Facebook Class
$logout = $facebook->getLogoutUrl();
// Redirect the user to the logout url, facebook will redirect him to our page
wp_redirect( $logout );
}
i actually redirected the user after unsetting facebook session. Remember that if you are setting an acces token programmatically in the instyance of the Facebook class you must invalidate the token too
Upvotes: 2