PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a site with a cart. I track the contents of the cart in a database, and use a cookie on the clients computer with a session ID in it to keep track of the shopper as they shop. On occasion, after adding a few things to the cart, the cart mysteriously empties.
Notes:
Running PHP 5.2.3 & MySql 4.1.22 on FreeBSD 6
It does not appear to be product specific.
In some cases, I might only add 10 products to the cart before the problem occurs, and in other cases I am able to add 200.
I have watched the headers from my browser to make sure they are correct.
This occurs with Firefox and IE, so I don't think it's browser specific.
I can see that the database table which contains the cart contents, that it is emptying whenever the problem occurs.
The session ID is correct and consistent everywhere (e.g. browser, database)
I have a function which empties the cart (used for "empty" cart button), but I don't believe that is getting called cause there's normally an associated message which prints out with it (e.g. "You have emptied your shopping cart").
With 100+ thousand lines of code, I can solve most problems, so my skills are okay in troubleshooting, however I am stumped on this one
I am not the programmer, please speak slowly and clearly.
How many places in your code can the cart database be emptied? If the records can only be deleted from that function, then most certainly that function is getting called somehow.
Problem is close to being solved : it appears that PHP garbage collection is being run whenever the cart is emptying. I can start shopping and create an error within a few minutes, or in other cases, half hour or more. Whenever it coincides that garbage collection is getting run, and I am editing my cart, then it was somehow running the empty cart function incorrectly. So, ultimately, it probably was incorrect coding + garbe collection triggering it.