[Pdx-pm] Shopping Cart Logic

Rob Bloodgood robb at empire2.com
Fri Mar 7 13:25:23 CST 2003

Hello Carl,

Friday, March 7, 2003, 8:53:01 AM, you wrote:

>> My problem is when a customer does not check out the records in the
>> shopping_cart table get abandoned.  I really don't like this idea.  I
>> could write a cron to delete the records that are x days old, but I am
>> wanting something that does not require an outside process.  What other
>> ways can I keep the database nice and clean?

CS> I would think that most shopping cart websites are best if a customer's
CS> cart contents stay active .. forever.  Yes, this creates a bloated
CS> database -- but you can do so much more...  Are you implimenting user
CS> sessions?  If so, when a session expires, flag the user record as "busy."  
CS> This infers that the user has gone away to think about the purchase .. for 
CS> however long it takes :)  Also, at the next login, you could perform 
CS> queries on dated cart items:

CS> "Welcome back, it looks like you had some items in your cart that we no 
CS> longer carry .. but CLICK HERE FOR SOMETHING BETTER."  I know bad example 
CS> -- but you get the idea.

CS> If you are absolutely against stale records in the database, keep all the 
CS> cart information in a cookie -- at least there's a /good/ chance the user 
CS> sees them again.

I dunno, I got tired of a large, inscrutable session table in my
database too, and eventually switched my Apache::Session backed to File
instead of Oracle.  That way, the session_id is still the only
information in the cookie, I take advantage of the optimizations in
the filesystem access & caching w/o worrying about database time, and expiring
old sessions is a simple cron/find/rm job.  But I've got sessions from
all the way to last Dec (last time I cleaned).  I have 3300 session
files, and they take a total of 13MB.  Messy to look at, sure, but
it's all in one folder, and most are <100 bytes!

A shopping cart should (IMHO) hold the items you have flagged, with the session_id cookie
itself having a LONG LONG timeout (years is ok with me!).  Then you
can look in the session data itself, expire old items, then keep


More information about the Pdx-pm-list mailing list