someguy321 Posted September 23, 2010 Share Posted September 23, 2010 I have a class "Login" that handles login, registration, checking if someone's logged in and authorization stuff. I would prefer to be able to instantiate this just once per session and then reuse that. however, I don't know if there's drawbacks to storing this object in the session. For example, will this lead to too much memory usage of the session object? Is it slow to keep retrieving an object from session? Would it be faster and better on the server to just re-instantiate and then destroy the object every page request? Quote Link to comment https://forums.phpfreaks.com/topic/214237-good-or-bad-idea-to-store-an-object-in-session/ Share on other sites More sharing options...
trq Posted September 24, 2010 Share Posted September 24, 2010 Why would you need to store and object that handles logging in /registration if your user is already logged in? Sounds like your object does more than it should. As for storing a users data in an object and storing that within a session, that would be fine, though I would drag too much data around within the session itself. You need to get a balance however between looking constantly re-querying a data source, or using sessions. It really depends on your application and environment. Quote Link to comment https://forums.phpfreaks.com/topic/214237-good-or-bad-idea-to-store-an-object-in-session/#findComment-1114885 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.