Save items in Localstorage for a shopping cart [closed]

0

I am working on an ASP.NET MVC 5 application with SQL Server to make a shopping cart, I have the following doubt regarding the recording of the data that users will be adding to the shopping cart, > I have 2 options

1 .- When the user adds an item to the cart, immediately record said data in the database. What I see against this form is that you will be interacting with the database too many times (and in the end I do not know if the user will buy something)

2 .- As soon as the user adds an item, they record it in Localstorage and when he really decides to make the purchase, he sends the data from the localstorage to the database. The problem with working with LocalStorage is that someone can raise the browser console and I can change the data in the LocalStorage with incredible ease.

How should this situation be handled? , because I do not think either of these options is correct, or in any case, does any of you know another way of working this situation?

Thank you for your attention.

    
asked by Michael V. 16.03.2017 в 20:24
source

1 answer

1

For this you can rely on popular shopping sites like Amazon, in which your shopping cart is kept in database and is available to you on any device. Imagine that the user makes the cart on his desktop PC but wants to finish the purchase on the mobile because he has to leave?

There is nothing wrong or wrong about using a database for this.

    
answered by 16.03.2017 в 20:30