您必須先致電javascript客戶端註銷第一個,然後將它們發送到您的PHP註銷腳本。所以,調用.js文件:
FB.Connect.logoutAndRedirect("/path/to/zend/logout/controller");
你會看到一個模式彈出,說:「你要登錄這個網站和Facebook *您會被重定向到任何地方您註銷腳本是:
try
{
$facebook->expire_session();
}
catch (FacebookRestClientException $e)
{
//you'll want to catch this
//it fails all the time
}
我平時也呼籲在PHP腳本註銷此功能,只要是安全的:
/**
* 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]);
}
謝謝!有用! :) – Abhinav 2009-09-07 13:28:17
yeap,作品!測試它沒有額外的功能_killFacebookCookies(),工作正常。 – Alex 2010-04-23 12:50:02