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

elqouent10's avatar

Storing Objects in Session

I am looking for some more experienced developers to take a fresh look at this stackoverflow question: http://stackoverflow.com/questions/132194/php-storing-objects-inside-the-session

I have an web app where there is a lot of information, primarily models (and other objects), being stored in the session across the many steps a user must take to checkout a product. I am weighing the pros and cons of storing the primary key, instead of the whole object in the session, and I'd like some help in identifying the pros and cons of each approach from a Laravel perspective.

If I don't store the objects in the session, I am concerned about the time / resources of hitting the database to fetch from three to four tables on each HTTP request. If I do store objects in the session, I am not sure as to how much overhead this causes. Are there any other pitfalls I could encounter?

0 likes
1 reply
elqouent10's avatar

Does anyone have any thoughts on this? Any discussion would be appreciated

1 like

Please or to participate in this conversation.