Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jameslkingsley's avatar

Storing Model Object in Session

I'm building an EPOS system and need to store the basket model object in the session, so that while the transaction is still open I can add products to the basket, compute some stuff and then when the transaction is finished, serialize and save it to the database.

I'm putting the basket model object in the session via session()->put('basket', $basket) but that only stores the accessible values, and not any of its methods.

Is there a way to persist model objects with their methods across multiple requests until ready to save them to storage?

0 likes
0 replies

Please or to participate in this conversation.