views:

192

answers:

1

I'm currently tearing my hair out trying to persist authentication via a database bases session. I've set Zend_Session to use a database, and on inspection, Zend is writing values to the database. However, the ID for those sessions doesn't appear to match the PHPSESSID - yet when I get Zend_Session to return the id - it returns a matching value.

So - in my DB I have:

ID.....MODIFIED.......LIFETIME...DATA

344..1265640083.......1440.......BLAH

Yet if I call the id from Zend Session itself...

$id = Zend_Session::getId();
echo $id; // mbgspg2gvf1c3r9l7qpv6orgt4

I'm assuming that the ID generated by Zend Session must match that of the PHPSESSID, correct?

Here's my bootstrap

    $dbAdapter = $resource->getAdapter();//connection is tested and working

    Zend_Registry::set("db", $dbAdapter);

    $config = array(
                    'name'           => 'sessions',
                    'primary'        => 'id',
                    'modifiedColumn' => 'modified',
                    'dataColumn'     => 'data',
                    'lifetimeColumn' => 'lifetime',
                    'db'             => $dbAdapter
                    );
    Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config));
    Zend_Session::start();

I will be eternally grateful if someone can shed some light on this one...

A: 

Well, I'm flummoxed. I changed the table type to InnoDB and now it works.

In my defence - in the main documentation it doesn't specify InnoDB: http://framework.zend.com/manual/en/zend.session.savehandler.dbtable.html

whereas here it does: http://framework.zend.com/wiki/display/ZFPROP/Zend_Session_SaveHandler_DbTable?showComments=false

I'm praying that's what fixed it. Perhaps a local bug in my Apache?

sunwukung