I'm creating a wishlist for an ecommerce website. I couldn't find a good article on this.
I need to create a wishlist that works for both a logged in user or guest user ( not logged in). So I did some analysis and have decided to use browser local storage for saving wish list items and sync them with the database when user logs in.
The technology in the current website is C# ASP.Net MVC and Jquery at client side.
My query is:
- Is there any alternative way to achieve this ?
- Is there any drawbacks in this approach ?

Nigel FernandesPosted Jun 16, 2017, 1:05 AM
Sameer ShaikPosted Jun 15, 2017, 4:49 AM
Sundaram SubramanianPosted Jun 15, 2017, 4:36 AM
when a user addes a product to his wish list, you make a cookie where you store the ProductID (primary key, int) from the database table where you store products
Response.Cookies["wishList"].Value = productID;Response.Cookies["wishList"].Expires = DateTime.Now.AddHours(2);
if the user already added before some products in his wish list (with other words, the cookie already exists - because you created when added first time), you make a new cookie with same name, but where you add the second product near first one
String cookieValue = Request.Cookies["wishList"].Value.ToString();cookieValue = cookieValue + "," + productID;
Response.Cookies["wishList"].Value = cookieValue.ToString();Response.Cookies["wishList"].Expires = DateTime.Now.AddHours(2);
now you have in a cookie the productID's of with that user wants in his wish list[;)]