Zend_Auth and database session SaveHandler
I have created Zend_Auth
adapter implementing Zend_Auth_Adapter_Interface
(similar to Pádraic's adapter) and created simple ACL plugin. Everything works fine with default session handler. So far, so good.
As a next step I have created custom Session SaveHandler to persi开发者_高级运维st session data in the database. My implementation is very similar to this one from parables-demo. Seems that everything is working fine. Session data are properly saved to the database, session objects are serialized, but authentication does not work when I enable this custom SaveHandler.
I have debugged the authentication and all works fine up till the next request, when the authentication data are lost.
I suspected, that is has something to do with the fact, that I use $adapter->write($object)
instead $adapter->write($string)
, but the same happens with strings.
I'm bootstrapping Zend_Application_Resource_Session
in the first Bootstrap method, as early as possible.
Does Zend_Auth need any extra configuration to persist data in the database?
Why the authentity is being lost?I have found the cause of the problems.
I used 'data' as a column name. Session SaveHandler from parables-demo was calling code similar to this:
$string = 'test'
$doctrineModel->data = $string;
echo gettype($doctrineModel->data); // displays 'Array', not string as some would expect
So the data I wanted to save were accidentally converted to arrays.
精彩评论