简体   繁体   中英

ASP.net shopping cart dilemma

I have designed a shopping cart that allows both login and non-login users to place stuff in it. The problem lies with non-login user, when they add items into the cart, it will be stored in their browser cookie as well as to my database with the cookie name as the ID, the next time they surf the site again as non-login user, my program will do a search & match, if the cookie on the user side is found then the cart will be returned.

Now if the user say add 20 items and delete their cookie right after, that would leave an "unattended" cart in my database. I think there's no way to make it in such a way that if the cookies are deleted on the client end, I want those "unattended" cart to be removed too. I have thought of not committing the quantity for non-login users till they sign in and migrate the anoynomous cart into their own account but that would sort of being biased towards login users and last thing I want is them coming back 3 days later and find all items goes out of stock.

Any advice? Thanks.

You could schedule a job on the database that will run at regular intervals and will delete let's say all anonymous carts that are older than 1 week.

In Global.asax delete "unattended" carts from database of particular session on session_start Event

because session_start event is fired when no cookies or session are found on browser

and when new session is started.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM