Arrays vs. Database for storing cart items
Posted: Sat Nov 30, 2002 3:14 pm
I've been debating using using multi-dimensional session arrays or a table in a MySQL database to store items for purchase in a shopping cart.
One question involves SSL. The majority of the cart is run outside of SSL using sessions to track customers as they move around. Now as I understand it the session id gets stored in a cookie (im not inserting the session id in the urls) and that's how the server matches clients with session variables. Once the customer has added all the items they want to the shopping cart, they will get sent to an https url for checkout(same server and same domain, just secure). Will going from a none secure to a secure connection force a new session or will the same variables carry over? In other words will customers lose their session variables when they switch to a secure connection?
Next. If I use a table in a database, I can't think of a fast way to clean the table of customers who chose items but didn't buy. They would quickly clutter up a table if you have people windows shopping but not buying.
I'm leaning toward arrays because they should be faster and they are self cleaning, that is its already handled by the server. I understand that it's more difficult to code item tracking with arrays, but isn't it worth it for the speed and flexibility. All the shopping cart tutorials I see that use a database to store items don't talk about garbage collection. I know I could use crontabs but that wouldn't be easy for other people to set-up and it wouldn't make for a very portable shopping cart.
What is everyone elses feeling on the matter.
Thanks in advance.
One question involves SSL. The majority of the cart is run outside of SSL using sessions to track customers as they move around. Now as I understand it the session id gets stored in a cookie (im not inserting the session id in the urls) and that's how the server matches clients with session variables. Once the customer has added all the items they want to the shopping cart, they will get sent to an https url for checkout(same server and same domain, just secure). Will going from a none secure to a secure connection force a new session or will the same variables carry over? In other words will customers lose their session variables when they switch to a secure connection?
Next. If I use a table in a database, I can't think of a fast way to clean the table of customers who chose items but didn't buy. They would quickly clutter up a table if you have people windows shopping but not buying.
I'm leaning toward arrays because they should be faster and they are self cleaning, that is its already handled by the server. I understand that it's more difficult to code item tracking with arrays, but isn't it worth it for the speed and flexibility. All the shopping cart tutorials I see that use a database to store items don't talk about garbage collection. I know I could use crontabs but that wouldn't be easy for other people to set-up and it wouldn't make for a very portable shopping cart.
What is everyone elses feeling on the matter.
Thanks in advance.