dadamssg87 Posted October 12, 2011 Share Posted October 12, 2011 My application i'm developing has the potential to store, what i consider, quite a bit of data into sessions per user and it keeps breaking. I can't say for certain that it's a session storage issue. I'm storing shopping cart items and after i store a certain amount of items and try to add more it will keep the old items but won't store the new items. So i'm 90% sure it's the session storage limit. What i'm considering doing is only storing a session id in the session. Then as the user adds items to their cart, those items get stored temporarily in a table in my database with that session id. So instead of pulling it from my session, i'd be pulling it from a certain database table. I'm guessing thats the best way to handle this issue? I'm developing locally with MAMP and all its default settings. Quote Link to comment https://forums.phpfreaks.com/topic/248941-disadvantages-from-storing-what-would-be-in-a-session-into-a-db-table/ Share on other sites More sharing options...
trq Posted October 12, 2011 Share Posted October 12, 2011 You can use a database to store your session data if that helps. See session_set_save_handler. Quote Link to comment https://forums.phpfreaks.com/topic/248941-disadvantages-from-storing-what-would-be-in-a-session-into-a-db-table/#findComment-1278465 Share on other sites More sharing options...
dadamssg87 Posted October 12, 2011 Author Share Posted October 12, 2011 i'm not sure i understand enough about php's default method to store session data to use that function. I see that in one guy's example in the comments section he uses the blob datatype. I can't say i understand the blob datatypes. I also don't understand how arrays get stored by the session. Could you possibly show me a really simple way to store session data in a database table effectively? Quote Link to comment https://forums.phpfreaks.com/topic/248941-disadvantages-from-storing-what-would-be-in-a-session-into-a-db-table/#findComment-1278478 Share on other sites More sharing options...
PFMaBiSmAd Posted October 12, 2011 Share Posted October 12, 2011 It would take storing 10's of thousands of large pieces of information in a session to cause a problem (the size is limited by available memory and by the size of file that the operating system can manipulate.) Also, switching to database storage of large pieces of information will run into a problem with the database maximum packet size that can be transfered at one time. It is always best to find and fix the cause of a problem, rather than throw code at a problem and hope that the problem magically gets fixed. Your description of the problem sounds more like a logic error in your code. A memory size issue would produce php errors alerting you to the fact that there was a memory problem. Quote Link to comment https://forums.phpfreaks.com/topic/248941-disadvantages-from-storing-what-would-be-in-a-session-into-a-db-table/#findComment-1278479 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.