I have Object that performs not only registration/Login but also manages users after the log in. Does it make sense to store object of that class in session or I should only store userID on session and use that to Query DB? My Object will contain user details (Full name, Username et al).

Which makes more sense? If I'm not clear, please let me know. I'm trying to make usable User Management Class that I will be using in all My system for login/register and user management in general (ACL).


7 Years
Discussion Span
Last Post by Stefano Mtangoo

Objects which can not be serialized or are composed of objects that can't be serialized will cause headaches with your sessions for starters.

In my experience there is a bigger performance hit for the server to serialize and unserialize session data than there is to recreate the objects from persistent storage, especially if the object collection grows and grows.

Votes + Comments
Very useful!

That is very useful. It means I better create objects than "hide" them in sessions. I was having that though only with no rational reason! Thanks for that!

And what about the best way to deal with user information? Put them as attribute of object (Array) or store Id in session and Pull the rest from DB using that ID?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.