[thelist] Re: Which way is best? (was: Homemade Shopping Cart )

Rob Smith rob.smith at THERMON.com
Wed Nov 26 10:45:45 CST 2003

I think I've found a solution to my problem, which is a happy medium to my
which way is best shopping cart. It involves a temporary table and no
cookies nor session variables.

Legend to ASCII Art
[ ] - checkbox
[*] - checked checkbox
[X] - grayed out / disabled product 

I have a short list of unique products:
3245	Letter A	$0.99	[ ]
2487	Letter B	$1.25	[ ]
8437	Letter C	$0.50	[ ]
3493	Letter D	$3.99	[ ]

Then a users "reserves" a few items:

3245	Letter A	$0.99	[ ]
2487	Letter B	$1.25	[*]
8437	Letter C	$0.50	[*]
3493	Letter D	$3.99	[ ]

At this point, when the user clicks [Add], the items are added to a
temporary table. The a  timestamp is placed on this item as a supplemental
column. Before this same product list is displayed once more, I check the
temporary table for "expired" products. (I've enabled a 15-minute
expiration.) If a product has not been purchased before the expired time,
then the product is made available once again:

"Reserved Product":
3245	Letter A	$0.99	[ ]
2487	Letter B	$1.25	[X] (timestamp :: 3:50pm)
8437	Letter C	$0.50	[X] (timestamp :: 3:40pm)
3493	Letter D	$3.99	[ ]

Time is now 4:03pm and no items purchased:
3245	Letter A	$0.99	[ ]
2487	Letter B	$1.25	[X] (timestamp :: 3:50pm)
8437	Letter C	$0.50	[ ] <-- expired and becomes available
3493	Letter D	$3.99	[ ]

Like I said before, the items are removed from my temporary table if they
have expired, BEFORE the list is displayed. I achieved the 15-minute
expiration time by doing:

DELETE FROM myLetters Where EnteredTime < '" & DateAdd("n", -15, now()) & "'

' which is pretty darn cool.

I choose this approach, because of the idea that an order could have been
abandoned mid-way through and the actual real data would not be effected. I
choose not to go with cookies because they can be deleted rather easily and
will eventually expire, either with your set date, or the computers die. :-\
Session variables also have that annoying 20-minute default expiration time.
However, my experience with doing Session.timeout = 90, still isn't
effective. They still expire. At least with a temporary table, the
information is somewhat temporarily permanent :-\ and I have greater control
over what goes and what doesn't. Call it a power trip.

The overhead involved with this approach is when the user actually goes
through with the order, all I have to do is update the availability on the
actual data from the temp table, which can be done in one move.

Your thoughts? warnings? 


More information about the thelist mailing list