I need to keep my basket more permanent I have two options and I want to choose the best one.
I have eCommerce web site application in asp.net and there is a basket include products which are selected by users before, so options:
1- keep basket in database (consider the cost and time to store and retrieve information)
2- store my basket in Cookies (I don’t know what the implementation is)
I couldn’t use session because it is not permanent and clear by closing browser.
My goal is : when the user close the IE for 1 day or 2 days make ability to remember all products that already added to basket.
In addition, my basket is store in hash-table now, for example : {1:4055,2:4588,…} they are ID and product code(keys). they are all save in a hash table.
Please give me a solution and the way to how I can implement it with the minimum cost ?
The minimum cost for whom and for what? Do you want to be memory / disk efficiant on the server? Do you want to be cost effective when programming?
If you want to be cost effective considering space, you can always use cookies, but you can’t really trust cookies, so I wouldn’t store everything in there.
What you could do is to store a “Basket Id” in a cookie, that references a Basket in your data store. What you would also like to do is to store the “Begin Purchase” on the basket, because this way you could clean up all baskets after a couple of days with a nice sql job.
There are a lot of ways to solve this, but I would not store everything inside the cookies, just store a reference there. So I would definetly go with database!.
You should check out the “MVC Music Store Tutorial” over at http://www.asp.net to get some more information on how to buld an online shop.