Zend: Fetching row from session db table after generating session id

Posted by Nux on Stack Overflow See other posts from Stack Overflow or by Nux
Published on 2010-03-22T23:44:54Z Indexed on 2010/03/22 23:51 UTC
Read the original article Hit count: 363

Filed under:
|
|

Hi,

I'm trying to update the session table used by Zend_Session_SaveHandler_DbTable directly after authenticating the user and writing the session to the DB. But I can neither update nor fetch the newly inserted row, even though the session id I use to check (Zend_Session::getId()) is valid and the row is indeed inserted into the table. Upon fetching all session ids (on the same request) the one I newly inserted is missing from the results. It does appear in the results if I fetch it with something else. I've checked whether it is a problem with transactions and that does not seem to be the problem - there is no active transaction when I'm fetching the results. I've also tried fetching a few seconds after writing using sleep(), which doesn't help.

$auth->getStorage()->write($ident);
//sleep(1)
$update = $this->db->update('session', array('uid' => $ident->user_id), 'id='.$this->db->quote(Zend_Session::getId()));
$qload = 'SELECT id FROM session';
$load = $this->db->fetchAll($qload);
echo $qload;
print_r($load);

$update fails.
$load doesn't contain the row that was written with $auth->getStorage()->write($identity). $qload does contain the correct query - copying it to somewhere else leads to the expected result, that is the inserted row is included in the results.

Database used is MySQL - InnoDB.

If someone knows how to directly fix this (i.e. on the same request, not doing something like updating after redirecting to another page) without modifying Zend_Session_SaveHandler_DbTable: Thank you very much!

© Stack Overflow or respective owner

Related posts about zend-framework

Related posts about php