سؤال

I currently have a ColdFusion shopping cart script I have written which stores all of the users items in a session variable. Looking through it, I'm wondering what if there is a more robust solution for shopping cart data? Is it better to temporarily store cart data into a db table or to store the cart data in the users session?

My cart currently houses several hundred array items as the site I have is quite big. So I guess I'm wondering what is the better solution, DB or session ?

هل كانت مفيدة؟

المحلول

I would make the cart data persistent in the database.

This has 2 main advantages: it adds business value and reporting capabilities, allowing you to (for e.g.) analyze which carts are abandoned. The second advantage is that you can cluster your application more easily, over different clients, and your application will need less operative memory to run, allowing the application's memory behaviour to be more predictable.

نصائح أخرى

Both options are OK, the choice depends on your priorities. Database would be interesting if you intend to keep the carts longer than one session. You can also consider using something like Redis to persist user sessions (across several CF servers).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top