Page 1 of 1

Handling obsolete shopping cart info

Posted: Tue Jan 27, 2004 3:16 am
by serap
Im trying to figure out how to handle obsolete shopping cart info when a customer adds items (to be bought) and returns 1 day later to find the same items still in the cart. I use cookies to identify the customer. Im very new to php but know coding on general. Think there are two ways (please advice if there is more!):
1) to somehow delete from the shopping cart table when customer closes the browser(s) - for his cookieID
or
2) to modify the cookie lifetime so that it is not living long in the users pc (i use 365 days)

what is the best practice of the above? and are there any predefined functions for 1)

thanks
Serap

Posted: Tue Jan 27, 2004 3:56 am
by twigletmac
Add a date field into the database which says when the user added the item. When the user returns check whether that date is past the date which the items should be removed from the cart and delete expired items and only show current ones.

Mac

Posted: Tue Jan 27, 2004 4:30 am
by markbeadle
After adding a date to the database you can also have a cron job which deletes items in the cart after a fixed time has passed (2+ days to allow for if someone if shopping at midnight). Or move the items to another table for reporting purposes (Items added to cart but not brought).

This will keep the cart table smaller.

Posted: Wed Jan 28, 2004 11:37 am
by serap
ok thanks for the tips - Ill try them out.

Are there any browser dependent PHP functions that can trigger when registering browser actions?

Posted: Wed Jan 28, 2004 1:35 pm
by Derfel Cadarn
Browser-dependent PHP-functions? Don't think so: PHP is server-side.