How to log out users using Facebook Connect in PHP and Zend?

Answer

 

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
 */protectedfunction _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]);}

All zend-framework Questions

Ask your interview questions on zend-framework

Write Your comment or Questions if you want the answers on zend-framework from zend-framework Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---