php - Zend_Session_SaveHandler_DbTable is wiping the Session with every refresh? -


i'm encountering same problem poster in this question. database initialized properly. i've tried doing initialization of both database , session savehandler in application.ini , in bootstrap. same result no matter how it.

here's application.ini initialization looks like:

resources.db.adapter = "pdo_mysql" resources.db.params.host = "localhost" resources.db.params.username = "uname" resources.db.params.password = "******" resources.db.params.dbname = "dbname"  resources.session.savehandler.class = "zend_session_savehandler_dbtable" resources.session.savehandler.options.name = "sessions" resources.session.savehandler.options.primary = "sessionid" resources.session.savehandler.options.modifiedcolumn = "lastmodifiedtime" resources.session.savehandler.options.datacolumn = "data" resources.session.savehandler.options.lifetimecolumn = "lifetime" 

and here's bootstrap initialization looked like:

protected function _initsession() {         $db = zend_db::factory('pdo_mysql', array(             'host'        =>'localhost',             'username'    => 'uname',             'password'    => '******',             'dbname'    => 'dbname'         ));         zend_db_table_abstract::setdefaultadapter($db);       $sessionconfig = array(              'name'           => 'sessions',                   'primary'        => 'sessionid',                'modifiedcolumn' => 'lastmodifiedtime',                  'datacolumn'     => 'data',             'lifetimecolumn' => 'lifetime'         );          $savehandler = new zend_session_savehandler_dbtable($sessionconfig);          zend_session::setsavehandler($savehandler);          zend_session::start();  } 

my sessions database table defined follows:

create table sesssions (     sessionid char(32) primary key not null,      lastmodifiedtime timestamp,      lifetime timestamp,      data text ) engine=innodb; 

i have test action tests through simple 1 field form dumps contents session. action looks this:

public function addaction() {     $namespace = new zend_session_namespace();      $form = new application_form_addtosession();     $request = $this->getrequest();     if ($request->ispost()) {         if ($form->isvalid($request->getpost())) {            $namespace->content = $request->getparam('toadd');         }     }     $this->view->form = $form;  } 

here's form uses:

class application_form_addtosession extends zend_form {      public function init()     {         $this->setmethod('post');          $this->addelement('text', 'toadd', array(             'filters'    => array('stringtrim', 'stringtolower'),             'validators' => array(                 array('stringlength', false, array(0, 256)),             ),             'required'   => true,             'label'      => 'add:',         ));          $this->addelement('submit', 'add', array(             'required' => false,             'ignore'   => true,             'label'    => 'add',         ));      }   } 

the view shows form.

to test whether or not value went session, use index action. index action in question:

public function indexaction() {     $namespace = new zend_session_namespace();     echo 'content: '.$namespace->content.'<br>';     echo '<pre>'; print_r($_session); echo '</pre>'; } 

now. if don't have session saving configured use zend_session_savehandler_dbtable, ie, if don't have session saving configured @ all, works fine. enter value in form field, go index action , have output me. session works way supposed to.

if have zend_session_savehandler_dbtable configured in either application.ini or bootstrap, when enter value test field , go index action value gone. database table has row proper sessionid , sessionid matches cookie in browser. there no other information in database. data null , both timestamp fields zeroed out.

i've run out of things try. i've had mysql table regular table , innodb table. i've tried every permutation of database , session configuration can come with, including giving db configuration array, , initializing 1 in bootstrap , other in .ini. i've scoured web , stackoverflow clues. i've seen other people post similar problems, none of answers i've found have worked. haven't done? have screwed up? how can make work?

the problem defined lastmodifiedtime , lifetime columns timestamp. should int instead:

create table  `sessions` ( `sessionid` char(32) not null, `lastmodifiedtime` int, `lifetime` int, `data` text, primary key (`sessionid`) ) engine=innodb default charset=utf8; 

after small modification should work.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -