2014-07-15 76 views
2

晚上好,我有這段代碼,但是我需要知道這是否真的記錄了,但沒有成功,我錯了?這scritp沒有告訴我任何錯誤:(使用Zend_Auth驗證會話的問題

    $userDetails = array('foo' => 'bar'); 
$storage = new Zend_Auth_Storage_Session(); 
// set sorage for Zend_Auth 
Zend_Auth::getInstance()->setStorage($storage); 
// write data to the storage 
Zend_Auth::getInstance()->getStorage()->write($userDetails); 
// read data from storage 
$c = Zend_Auth::getInstance()->getStorage()->read(); 
    $result = $c->authenticate($userDetails); 
          echo $this->view->form = var_dump($result); 

if (!$result->isValid()){ 
    var_dump('FAILURE'); 
}else{       
    $this->_helper->redirector('index','index'); 

} 
+0

你想檢查是否用戶會話存在?? –

+0

是!................. – user3680708

回答

0

你可以檢查在Zendsession

if (Zend_Auth::getInstance()->hasIdentity()) { 
    // do user session action 
} else { 
    // redirect to login page 
} 

獲取用戶信息嘗試,

$userInfo = Zend_Auth::getInstance()->getStorage()->read();