I am creating a Laravel 5 store shopping cart and I would like to allow the users to compare up to 3 or 4 items. I'm not sure if my thinking is correct, but my idea is that I can have a "compare" button for each product that would fire an AJAX call to a route that would set a cookie in my controller. I could then read that cookie in another view to display the comparison. The alternative is to use a database to store the id's, but I'm not certain that is the best solution either.
Is there a better way? Also, can use an array as a cookie so that I can push/pop product ids somehow? Are there any simple examples out there to get me on the right track? I'd love to hear some suggestions to see what others are doing to handle this type of feature. Thanks!
Well, basically you're on the right track. But dont use cookies. store the ids in the session or on the database.. i think database is better because you can keep a history of what the customer compared.
Great! I appreciate the feedback. I will try sessions first and then try a database to see which is more effective for me.
I agree.. I would do the same DB!. So you can keep customer history and product history, even google can index it.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community