Farhad Mortezapour
Farhad Mortezapour

Reputation: 228

ASP.NET MVC when remove shopping cart from database?

I made a shopping cart through this example.

The question is, when the user adds the products to the cart and stores it in the database, but does not log in or register and leave the site, then when should the cart items be deleted from the database and how?

Upvotes: 0

Views: 463

Answers (1)

Dhaval Pankhaniya
Dhaval Pankhaniya

Reputation: 1996

you can do following things

1) if user is unauthorized and adds item then you can assign it an unique id


2) you can create cookie to store that id at client side


3) store items in database using that id


4) in case session gets timed out you can read that cookie and retrieve id


5) you can fix a time duration(example : 1 week) for that items if user takes no action on them you can clean it up.

Upvotes: 2

Related Questions