Problem logging out of Facebook site and wiping out sessions

I cannot get the facebook connect app I am building to register a user (sorry, no url as it is still in dev). Every time the user clicks on the link with the "logout" class, the following JS runs that seem to work and even show the mod is FB, stating that the user is logged out.

$(document).ready(function(){
    $('.logout').click(function(){
        //Kill facebook Session
        FB.Connect.logout(function() {
            window.location = $('.logout').attr("href");
        });
    });
});

      

Upon reaching the callback above, JS sends the user to a logout page where PHP again forcibly deletes the user session and ensures that the FB session is deleted. The user is then sent back to the page they were on when they clicked the "Logout" link.

//Remove our site session
Auth::logout();



/* FAIL
//Send user to FB logout page and then back here
$logout_url = $this->fb->get_logout_url( site_url( $return_to ? base64_url_decode($return_to) : '' ) );

// Clear any stored state
$this->fb->clear_cookie_state();

exit(header("Location: ". $logout_url));
*/



//FAIL
//$this->fb->logout( site_url( $return_to ? base64_url_decode($return_to) : '' ) );


//FAIL
//Remove user (is this needed..?)
//$this->fb->set_user(NULL, NULL);


//Remove the FB session cookies (in case the JS didn't)
$this->fb->clear_cookie_state();


// Redirect to privious page
redirect( ( $return_to ? base64_url_decode($return_to) : '') );

      

However, this whole process results in the user returning to where they were and still signed in. A second click on the link seems to do the trick and delete the session. I was tracking firebug (w / firecookie) and PHP logout pages were deleting FB session cookies, but still the next page loaded still uses them ?!

If anyone knows how completely DESTROY ALL FACEBOOKS ah ... sessions, then please speak up.

: EDIT: I even tried to manually delete all cookies on the logout page and still failed

if( $_COOKIE ) {

    foreach( $_COOKIE as $name => $value ) {

        //Get the current cookie config
        $params = session_get_cookie_params();

        // Delete the cookie from globals
        unset($_COOKIE[$name]);

        //Delete the cookie on the user_agent
        setcookie($name, '', time()-43200, $params['path'], '', $params['secure']);
    }
}

      

0


source to share


3 answers


My guess is that since you are running the api classes for Facebook, it reads the session and sets all cookies again, your Javascript call is just cleared.

The php facebook lib and FB js lib use the same cooken files. (so you can login via javascript and php lib will login as well).



There is a specific function to log out and navigate to the url:

FB.Connect.LogoutAndRedirect(url); 

      

+1


source


Just use the tag <fb:login-button>

and make sure you have it. autologoutlink='true'

Then when the user is logged in, print the tag <fb:login-button>

and it will show as "Logout"? Button

Hope it helps.



EDIT: Docos for login: http://wiki.developers.facebook.com/index.php/Fb:login-button

0


source


This worked for me (where the redirect page clears the server stuff)

            FB.logout(function(response) {
                window.location.href="/login/signout";
            });

      

0


source







All Articles