Zend会话身份丢失数据?

时间:2013-05-17 09:44:12

标签: php zend-framework session identity

我有问题。当我想使用$ auth-> hasIdentity()获取数据时,我失去了SESSION: 我的代码如下: 这是我的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

任何想法?

0 个答案:

没有答案