2011-11-28 93 views
2

所以我使用Facebook的PHP SDK用於驗證我的用戶....覈對Facebook的PHP SDK與Zend框架

,我試圖註銷使用destroySession()方法我的用戶base_facebook.php

這些都是在PHP SDK的base_facebook.php一些相關摘錄:https://github.com/facebook/php-sdk/blob/master/src/base_facebook.php

 public function destroySession() { 
     $this->setAccessToken(null); 
     $this->user = 0; 
     $this->clearAllPersistentData(); 
     } 

    protected function clearAllPersistentData() { 
    foreach (self::$kSupportedKeys as $key) { 
     $this->clearPersistentData($key); 
    } 
    } 

    protected function clearPersistentData($key) { 
    if (!in_array($key, self::$kSupportedKeys)) { 
     self::errorLog('Unsupported key passed to clearPersistentData.'); 
     return; 
    } 

    $session_var_name = $this->constructSessionVariableName($key); 
    unset($_SESSION[$session_var_name]); 
    } 

,但每次我嘗試這樣做,Zend框架會抱怨

Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'session has already been started by session.auto-start or session_start()' 

Zend_Session_Exception: session has already been started by session.auto-start or session_start() 

我該如何解決我的Facebook會話而不觸發所有這些錯誤?

+0

你有自己的班級擴展BaseFacebook嗎?或者你是否擴展Facebook類(反過來擴展了Facebook)? –

+0

如果Zend拋出這個異常,你應該檢查代碼並尋找其他可能的session_start(),也許在flashMessenger中?順便說一下,這段代碼來自擴展FacebookBase的Facebook類。也許你應該考慮編寫自己的類來存儲會話中的facebook數據,但使用Zend會話機制? –

回答

0

使用Zend_Session的先決條件是會話不能被初始化。 Facebook啓動它。作爲解決方案,請在使用Zend_Session之前調用session_write_close()。您也可以撥打session_destroy()來註銷facebook用戶。它銷燬與當前會話相關的所有數據。

1

爲了使其用Zend_Session工作,我修改了facebook.php源代碼和

$this->session = new Zend_Session_Namespace(); 
    $this->session->fb = array(); 

更換

session_start() 

然後替換出現的所有

$_SESSION" 

$this->session->fb