Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 668 Vote(s) - 3.42 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to log out users using Facebook Connect in PHP and Zend?

#1
I am trying to build a Connect app using PHP and the Zend Framework.
I also have a Zend_Auth based user authentication system.
Now, I am able to log in using Facebook but log out is not working.

I need to clear the Zend_Auth identity as well as remove all Facebook login info.
What would be the best way to do this?

I tried `facebook_client->expire_session()` and `facebook_client->clear_cookie_state();` together and also `facebook_client->logout($next)` after calling `Zend_Auth::getInstance()->clearIdentity()`

None of them seem to work.
Reply

#2
You have to call the javascript client logout *first*, then send them to your php logout script. So, call .js:

FB.Connect.logoutAndRedirect("/path/to/zend/logout/controller");

You'll see a modal popup that says "you are logging out of this site and facebook* You'll be redirected to wherever your logout script is:

try
{
$facebook->expire_session();
}
catch (FacebookRestClientException $e)
{
//you'll want to catch this
//it fails all the time
}

I usually also call this function in the PHP logout script, just to be safe:

/**
* Remove the local Facebook cookies that get set manually
*
* @return void
*/
protected function _killFacebookCookies()
{
// get your api key
$apiKey = $this->getConfig()->getApiKey();
// get name of the cookie
$cookie = $this->getConfig()->getCookieName();

$cookies = array('user', 'session_key', 'expires', 'ss');
foreach ($cookies as $name)
{
setcookie($apiKey . '_' . $name, false, time() - 3600);
unset($_COOKIE[$apiKey . '_' . $name]);
}

setcookie($apiKey, false, time() - 3600);
unset($_COOKIE[$apiKey]);
}



Reply

#3
You can logout the facebook user and redirect the user to your website page with PHP code like this :

header("Location: " . $facebook->getLogoutUrl(array('next'=>"http://yourwebsite.com/redirectAfterFacebookLogout.php")));
Reply

#4
(NEW FACEBOOK SDK)
For me the getconfig() wouldn't work.So I had to find the new functions from the base_facebook.php file and add this bit of code in it.
Then call it in your calling file. Before you do , call $facebook->destroySession();

public function _killFacebookCookies()
{
// get your api key
$apiKey = $this->getAppId();
// get name of the cookie
$cookie = $this->getSignedRequestCookieName();

$cookies = array('user', 'session_key', 'expires', 'ss');
foreach ($cookies as $name)
{
setcookie($apiKey . '_' . $name, false, time() - 3600);
unset($_COOKIE[$apiKey . '_' . $name]);
}

setcookie($apiKey, false, time() - 3600);
unset($_COOKIE[$apiKey]);
}
Reply

#5
(07-20-2023, 06:36 AM)cuddyhole219771 Wrote:

[To see links please register here]

You have to call the javascript client logout *first*, then send them to your php logout script. So, call .js:

    FB.Connect.logoutAndRedirect("/path/to/zend/logout/controller&quotWink;

You'll see a modal popup that says "you are logging out of this site and facebook* You'll be redirected to wherever your logout script is:

    try
    {
        $facebook->expire_session();
    }
    catch (FacebookRestClientException $e)
    {
        //you'll want to catch this
        //it fails all the time
    }

I usually also call this function in the PHP logout script, just to be safe:

    /**
    * Remove the local Facebook cookies that get set manually
    *
    * @return void
    */
    protected function _killFacebookCookies()
    {
        // get your api key
        $apiKey = $this->getConfig()->getApiKey();
        // get name of the cookie
        $cookie = $this->getConfig()->getCookieName();
       
        $cookies = array('user', 'session_key', 'expires', 'ss');
        foreach ($cookies as $name)
        {
            setcookie($apiKey . '_' . $name, false, time() - 3600);
            unset($_COOKIE[$apiKey . '_' . $name]);
        }
               
        setcookie($apiKey, false, time() - 3600);
        unset($_COOKIE[$apiKey]);     
    }
Thanks, seems to be the correct solution. If it was for Youtube/Gmail/Etc. it has a small url that does logout.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through