On Wed, Jun 12, 2013 at 3:19 PM, Ralf Eggert <[email protected]> wrote:
>> Take a look at the original PR that contains the new factories, as it
>> has examples showing how to use the various Session factories:
>>
>> - https://github.com/zendframework/zf2/pull/4268
>
> Actually, that PR was the only piece of documentation I found which I
> used to set up the SessionConfigFactory.
>
>> Note that they are not fully integrated into the various session
>> consumers in the framework yet; there's some issues we need to address
>> first. That said, in your own factories, you can then pull the session
>> service, individual containers, etc. and inject them into the objects
>> you need.
>
> Ok, that is clear when it comes to the session manager or session
> container stuff. But for the session configuration I would typically
> need that within the bootstrapping process because the session should be
> setup on each request. It does feel a little weird to request a service
> from the service manager to change the session configuration. Since I
> guess it is a basic feature will it not make sense to initialize the
> SessionConfigFactory automatically whenever a "session_config" block is
> found in the configuration data?

Not necessarily, actually. There's overhead in starting a session -
whatever save handler you have configured has to grab the existing
session from storage. If your page doesn't require a session, that's
overhead you don't need -- e.g., if it's a static page with no dynamic
elements, or API endpoints, etc.

So, typically, you'll grab the session and inject it into services
that interact with it (flash messenger, controllers, auth, etc.) --
that way, the session is only initialized when you actually need to
interact with it. This is, of course, why we haven't integrated it
entirely yet -- we have some open questions about how/when that should
happen. For now, you will initialize it when you need it. If that's on
every page, then do it via a bootstrap event listener.


--
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to