1
votes

For migration purposes, I use ZF1 and ZF2 modules in one project. Of course ZF1 modules should stick with Bit_Session_Namespace whereas ZF2 modules should use Zend\Session\Container. However, I have difficulties working with the same session data with these two different components.

As stated in the docs, I initialise ZF2 when working with ZF1 modules. This works fine. I log in to the application with a ZF1 module and both ZF1 and ZF2 modules can access the session data.

I already migrated the user module, which allows me to login via a ZF2 module. Suddenly, the session data (stored in a database) is stored as ArrayObjects instead of plain Arrays. Now it is still possible to read session data with Bit_Session_Namespace, however, manipulating session values have no effects at all.

My question: What do I have to do to get full access to the session from ZF1 and ZF2 components, no matter which component initialised the session? Does the ZF2 session needs to be configured differently? Do I have to init ZF1 when working in ZF2 modules? Thanks for any advice, I'm really stucked! If you need any code snippets, just drop a comment.

1

1 Answers

1
votes

Suddenly, the session data (stored in a database) is stored as ArrayObjects instead of plain Arrays.

There is an alternate strategy for storing sessions in ZF2, SessionArrayStorage. This is recommended when working with 3rd party libraries that access the session directly. In your case, ZF1 is the 3rd party library.