Facebook PHP Library only loading one user per browser
I'm integrating my site with Facebook, I used the Registration Plugin, handled the Registration process, and now in the frontend I check if the user is logged in:
FB.getLoginStatus(function(response){
if (response.status == "connected" && FB.getAuthResponse()) {
window.location.href = '<?php echo url_for('@facebook_login', true) ?>?token=' + session.accessToken;
}
});
Now This recognizes the last registered user (me), but when another user (my wife) enters on facebook, tha JS Api authenticates her as an already registered user, and redirects the app to the login URL but the PHP API is not detecting the user correctly.
This is the code I use for PHP, and it works for the last registered user, but not for the first registered user in the same browser.
$fb = new Facebook(array(
'appId' =开发者_运维百科> sfConfig::get('app_manda_free_facebook_app_id'),
'secret' => sfConfig::get('app_manda_free_facebook_app_secret')
));
if ($user_id = $fb->getUser())
{
$user = sfGuardUserPeer::retrieveByFacebookId($user_id);
if ($user)
{
$this->getUser()->signIn($user);
}
}
Any Ideas? I don't think this is the expected behavior, cause my site keeps refreshing trying to sign in the facebook user.
Please help this is driving me nuts!
This is clearly a problem with sessions and / or cookies. Have you tried to see the validity of such cookies or sessions and destroy them if they don't match? This is a practice I tend to do, since I've gotten this same issue often.
精彩评论