jscix Posted May 24, 2008 Share Posted May 24, 2008 I'm curious if anyone knows of any reason why persisting an object in a session could be a bad idea? Besides memory usage, and if anyone can answer this, how much memory usage would I be looking at by storing an object in a session? The object is merely a storehouse for user related data. (name, address, phone#, etc.) It also contains a few methods for manipulating that data.. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/107021-a-simple-question/ Share on other sites More sharing options...
Highlander Posted May 24, 2008 Share Posted May 24, 2008 The only problem as far as I know is the fact that you need to know if the data is valid. So, if the data in the database is updated, the session instance doesn't know about it. Other then that, it should be ok. Link to comment https://forums.phpfreaks.com/topic/107021-a-simple-question/#findComment-548778 Share on other sites More sharing options...
deadonarrival Posted May 24, 2008 Share Posted May 24, 2008 Why not store the data in a mysql (or sqllite?) database, then just store a reference to the row in the session? You'd have to store a few other bits of info in the db to authenticate the session user, IP for starters, but when you update the info then their session merely points to the data, rather than holding it. As highlander said, you cant update their session, but you can update the data it points to without having to update the session. Easier on memory, and faster too. Link to comment https://forums.phpfreaks.com/topic/107021-a-simple-question/#findComment-549099 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.