HDFilmMaker2112 Posted May 31, 2011 Share Posted May 31, 2011 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 https://forums.phpfreaks.com/topic/237994-store-shopping-cart-information-session-vs-cookies/ Share on other sites More sharing options...
fugix Posted May 31, 2011 Share Posted May 31, 2011 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 https://forums.phpfreaks.com/topic/237994-store-shopping-cart-information-session-vs-cookies/#findComment-1222880 Share on other sites More sharing options...
George Botley Posted May 31, 2011 Share Posted May 31, 2011 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 https://forums.phpfreaks.com/topic/237994-store-shopping-cart-information-session-vs-cookies/#findComment-1222892 Share on other sites More sharing options...
fugix Posted May 31, 2011 Share Posted May 31, 2011 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 https://forums.phpfreaks.com/topic/237994-store-shopping-cart-information-session-vs-cookies/#findComment-1222896 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.