When a user first hits my site's login screen, I have Facebook Connect determine if the user is logged into Facebook and reload the page if true:
<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"></script>
<script type="text/javascript">
FB.init('MY_API_KEY', '/xd_receiver.htm', { 'reloadIfSessionStateChanged': true });
</script>
When the page is reloaded, my backend PHP code checks if the user is logged into Facebook and then logs them in automatically to my site:
$Facebook = new Facebook(MY_API_KEY, MY_APP_SECRET);
if ($Facebook->get_loggedin_user()) {
// Log the user in.
}
That part works fine. The problem is with the logout functionality. My logout link currently looks like this:
<a href="#" onclick="FB.Connect.logoutAndRedirect('http://my.url/logout/');">Log Out</a>
When that's clicked, the user is successfully logged out of Facebook, but the backend Facebook PHP object still thinks the user is logged in ($Facebook->get_loggedin_user()
still returns their user ID), so my login code then logs them in again automatically.
So the problem I'm finding is that even though Facebook Connect logs the user out, the backend Facebook PHP object still considers the user logged in. Does anyone know how to overcome this? Can I not login the user automatically with my PHP code?
Thanks for any help!