Handling obsolete shopping cart info

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
serap
Forum Commoner
Posts: 31
Joined: Thu Jan 15, 2004 5:10 pm

Handling obsolete shopping cart info

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
markbeadle
Forum Commoner
Posts: 29
Joined: Tue Dec 02, 2003 2:50 am
Location: Aachen, Germany

Post 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.
serap
Forum Commoner
Posts: 31
Joined: Thu Jan 15, 2004 5:10 pm

Post 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?
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post by Derfel Cadarn »

Browser-dependent PHP-functions? Don't think so: PHP is server-side.
Post Reply