Zend-expressive-session: Session implementation enforcing json // Looking for an alternative

The Session class of zend-expressive-session does some json encoding and decoding in the Session::set method. The SessionInterface says “Values MUST be serializable in any format; we recommend ensuring the values are JSON serializable for greatest portability.”. And that’s what they are doing in their implementation and I’m fine with it :wink:

However, I’m currently migrating a ZF1 application to ZE3.
The ZF1 application stores a lot of stuff in the session.
For example whole Zend_Form instances.
These are serializable, but not JsonSerializable.

Question:
Does anybody know if there is an alternative implementation of the zend-expressive-session SessionInterface which does not enforce json format?

Thanks in advance

Steffen

I’d avoid storing objects in sessions: done it, burnt (multiple times) by it, never again for me :slight_smile:

In newer session implementations (also ones written by myself), I prevent non-scalar values from being put in the session in first place.

Writing an adapter that implements the zend-expressive-session interfaces is trivial: give it a shot, if that is really a blocker for you.

1 Like

Thanks for the answer, we ended writing an adapter.

The application we’re dealing with is a monstrosity where almost everything is stored in the session.
I appreciate your input and I guess you’re right, but changing the behaviour would be to much right now.

I just thought someone else must have had the same problem :slight_smile:

Regards

Steffen