Jump to content

disadvantages from storing what would be in a session into a db table?


dadamssg87

Recommended Posts

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. 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.