0

I have one table that hold all products by users were added to cart I need to know how can I delete items in the cart table when a user clear its browser cookies just delete its items already added to the cart ! I used AnonymousID identifier for anonymous users and store AnonymousID value in the cookie when user click ( Add To Cart ) button then populate cart table in the database with AnonymousID (AID) column, but the problem is that when user clear its browser cookies AnonymousID property will change to a new value that already not exist in the cart table So records not matching to delete what is the best solution to do that.

here is cart table ID = cart ID, AID = Anonymous-ID, and Item ID

enter image description here

Rebin Qadir
  • 291
  • 4
  • 12
  • May be set a cookie then check if it still exists.. if doesn’t then delete from shopping cart table https://stackoverflow.com/a/13272244/3254405 – boateng Sep 13 '18 at 21:59
  • I have set AnonymousID identifier in the cookie but the problem is when user clear its browser cookies AnonymousID will change to another value that not exist in the cart so records wouldn't delete. – Rebin Qadir Sep 14 '18 at 08:29
  • In https://www.nopcommerce.com/ open source shopping cart they have something similar, you can download and check the source how they do it which may be only for logged in users.. Do you really need to save shopping card older than 1 month and why would non-technical users delete their cookies.. – boateng Sep 14 '18 at 12:18
  • @numbtongue thank you for your comments I can use SQL Server Job to perform schedule to delete old items in the cart table but the web host is shared I haven't access to Sql Server. – Rebin Qadir Sep 14 '18 at 18:00
  • When adding new row can you also check for old/expired ones and delete them.. – boateng Sep 14 '18 at 18:05

0 Answers0