0

我有个问题。当我想使用 $auth->hasIdentity() 获取数据时,我失去了会话:我的代码如下:这是我的 Bootstrap.php

public function _initSession(){
    Zend_Session::start();
}


protected function _initDB(){ 
    $db = Zend_Db::factory('PDO_MYSQL', array ('host' => 'localhost', 'username' => 'root',  
                                                                        'password' => '111111',  
                                                                        'dbname' => 'your_tour')); 
    $db->setFetchMode(Zend_Db::FETCH_BOTH); 
    Zend_Db_Table::setDefaultAdapter($db); 
    Zend_Registry::set('DB',$db);
    return $db; 
} 

我在这里写 SESSION(在 loginAction 中),当我使用 var_dump 时它会打印正确的数据

$storage = $auth->getStorage();
 $storage->write($authAdapter->getResultRowObject(null,'password')); 
 Zend_Session::rememberMe(3600); // remember me for one hour 
 //$sess->lock(); 
 var_dump($_SESSION); //It shows the right data what I need to store ...

indexAction,我得到了 SESSION 但它什么也没返回

var_dump(Zend_Session::isStarted()); //Check for the Zend_session::start and it's TRUE
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity()){
    var_dump('nothing'); //return nothing
}
$infoUser = $auth->getIdentity();
var_dump($infoUser->user_id); //return null
var_dump($_SESSION); //nothing in here

有任何想法吗?

4

0 回答 0