Jump to content

Store Shopping Cart Information - Session vs. Cookies


Recommended Posts

What's the best way to store shopping cart information? I want things to stay in the cart for up to 2 weeks after they're added, without the need for somebody to log-in to their account to store them. Should I store the information in a database some how and then set a cookie referencing the cart_id in the db?

Link to comment
Share on other sites

you could store the information inside of a database...and have a field with the date that you want the information to expire..then write a script to delete that row when the current date is equal to the date that you have stored

Link to comment
Share on other sites

As fugix says,

 

 

Store the values in a database, after inserting, set a COOKIE with the ID of the entry or create your own Id's. Using sessions is not recommended as they are destroyed on session closure (browser closure).. Cookies can also be removed so it may not be possible to store it for 2 weeks for everyone.

 

 

It is dependant on the users preferences, but the method explained will work.

 

 

George.

Link to comment
Share on other sites

As fugix says,

 

 

Store the values in a database, after inserting, set a COOKIE with the ID of the entry or create your own Id's. Using sessions is not recommended as they are destroyed on session closure (browser closure).. Cookies can also be removed so it may not be possible to store it for 2 weeks for everyone.

 

 

It is dependant on the users preferences, but the method explained will work.

 

 

George.

right, and upon the destruction of the cookie after 2 weeks...simply set a delete clause to delete the row where the information is stored

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.