Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$facebook->getLogoutUrl(); link doesn't log user out of facebook

My current user story is that user1 is logged into my website and facebook (these accounts are connected etc).

User1 logs out of my site but not facebook.

After this user2 logs into his account, but the left over session from user1 screws with user2's interaction with my site and who they post as.

So to fix this I made it check if the user who is logged in actually owns the currently logged in facebook (this would result in them going to facebook log out etc) and it shows a link that should allow the user to log out...

Upon clicking the link they go to facebook and return to the site. But if you open a new tab and go to facebook User1 is still logged in.

How can I get this link to work.. what's going on. Is this a bug with the api or what?...

Edit: I've continued testing with value user ids loading and with valid access tokens but I have yet to get the logout link to work.

like image 529
Brandon Martinez Avatar asked Oct 06 '11 21:10

Brandon Martinez


People also ask

How come Facebook won't let me log out?

Log out of all devices on facebook.com on your PC On the pop-up, select Settings & privacy, and then Settings. Next, click Security and login in the sidebar on the left side. Click See more under “Where you're logged in). Click Log out of all sessions.

How do I log out of my Facebook account?

Tap in the top right of Facebook. Scroll to the bottom and tap Log Out. If you've logged into your Facebook account on multiple devices, you'll need to log out of each device separately.

How do I see what devices are logged into my Facebook app?

Facebook Login Locations: how to check Facebook login devices? Tap the menu icon (three lines) in the Facebook app on your Android or iOS device, then Settings & Privacy, then Settings. Security and Login are where you'll be able to update your password and examine your logged-in devices.


2 Answers

A little late but here goes my contribution:

Use the params when you generating the logout url, there redirects to a page in which you destroy the session using the Facebook API function for that.

Here an example:

$logoutUrl = $facebook->getLogoutUrl(array("next" => "http://mydomain.com/page4logout"));

In the page4logout you can instance the facebook object and execute the following:

$facebook->destroySession();

After that you can do a redirection.

like image 74
Luis Fernando Villegas Avatar answered Oct 14 '22 00:10

Luis Fernando Villegas


delete the facebook cookie and session manually. Here is my solution how I solved the problem some time ago, it think it's a bug of Facebook:

setcookie('fbs_'.$this->getAppId(), '', time()-100, '/', $_SERVER["SERVER_NAME"]);
unset($_SESSION['fb_'.$this->getAppId().'_code']);
unset($_SESSION['fb_'.$this->getAppId().'_access_token']);
unset($_SESSION['fb_'.$this->getAppId().'_user_id']);
unset($_SESSION['fb_'.$this->getAppId().'_state']);

$this->getAppID is your Facebook App ID, should be clear ;o)

like image 4
Tobias Bambullis Avatar answered Oct 14 '22 00:10

Tobias Bambullis