You can use a smarter auth storage. Doctrine's Auth storage adapter stores only the identifier: https://github.com/doctrine/DoctrineModule/blob/0.7.0/src/DoctrineModule/Authentication/Storage/ObjectRepository.php
Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 19 February 2013 10:11, roberto blanko <robertobla...@gmail.com> wrote: > Okay, that makes sense. But how else can I solve my problem? A way would be > not to store the entire user object in the session but only the user id. > But how can I realize that with an Auth adapater without having to fetch > the actual user object by handy every time i need it? > > > On Tue, Feb 19, 2013 at 10:05 AM, Marco Pivetta <ocram...@gmail.com> > wrote: > > > You are trying to store objects that are un-serializable into a session > > (like an event manager or similars). Don't do that. > > > > Marco Pivetta > > > > http://twitter.com/Ocramius > > > > http://ocramius.github.com/ > > > > > > On 19 February 2013 09:47, roberto blanko <robertobla...@gmail.com> > wrote: > > > >> Hello fellow devs, > >> > >> I use a custom authentication adapter to authenticate. The > authenticate() > >> method returns a Zend\Authentication\Result object with my cutsom user > >> object in it. As long as the user object was created with `new User()` > >> this > >> worked pretty fine. The user is stored in the session, which is being > >> stored in the DB. > >> > >> Now I changed my User class to implement ServiceManagerAwareInterface in > >> order to be able to access the service manager within my model. In order > >> for this to work, I cannot instantiate my user object with `new User()` > >> but > >> instead with $this->sm->get('My\Model\User'). I created the associated > >> invokable first. > >> > >> Since I changed that, the user cannot be stored by the SessionManager > >> anymore. I get an exception: > >> > >> 'Exception' with message 'Serialization of 'Closure' is not allowed' in > >> > >> > /vendor/zendframework/zendframework/library/Zend/Stdlib/ArrayObject.php:323 > >> Stack trace: > >> #0 > >> > >> > /vendor/zendframework/zendframework/library/Zend/Stdlib/ArrayObject.php(0): > >> serialize() > >> #1 [internal function]: Zend\Stdlib\ArrayObject->serialize() > >> #2 /vendor/zendframework/zendframew in > >> > >> > <b>/vendor/zendframework/zendframework/library/Zend/Session/SessionManager.php</b> > >> on line <b>166</b><br /> > >> > >> I use ZF 2.1 > >> > >> Do you have any idea why this is and how to fix it? Any help would be > >> highly appreciated. > >> > >> Regards > >> Rob > >> > > > > >