Noticed a small bug in shopping cart mechanism.
Below is a sample row from CMRC_ShoppingCart database table:
RecordID: 9
CartID: e7e3957d-4154-498a-954b-f602ec3dff0a
Quantity: 1
ProductID: 401
DateCreated: 25/01/2005 11:40:58
If you register as a user and login the shopping CartID GUID gets updated with the CustomerID.
RecordID: 9
CartID: 21
Quantity: 1
ProductID: 401
DateCreated: 25/01/2005 11:40:58
If you click 'Final Checkout' the stored procedure CMRC_ShoppingCartEmpty executes.
DELETE FROM CMRC_ShoppingCart
WHERE
CartID = @CartID
There is also a SP that is run nightly by a scheduled SQL job which deletes shopping cart entries that are more than a day old.
DELETE FROM CMRC_ShoppingCart
WHERE
DATEDIFF(dd, DateCreated, GetDate()) > 1
** BUG **
User goes through the shopping process and adds items to his cart.
Systems sets CartID equal to GUID.
User signs in.
CartID updated to ID of customer.
User gets as far as 'Final Checkout' stage but decides against it.(CMRC_ShoppingCartEmpty not executed).
User closes browser.
User returns an hour or so later to restart the shopping process. This time he
chooses completely different products and quantities.
When the user logs in his CartID GUID is replaced by his CustomerID.
The items from the session 2hrs earlier are still in the shopping cart - so he see's the items he has just added to his cart and the items from the previous session.
Any suggestions on how to best combat this?