Reputation: 1892
I'm making a website which displays a big list of items, similar to how eBay lists items. For each item there is a button that allows you to save it to your "wish list," and a link that brings you to a page that lists all the items on your wishlist.
How would I go about implementing this? I am currently using Javascript cookies and passing the values in the URL for PHP to pick up and display the wish-listed items. It feels like there must be an easier/better way to do this though. Any suggestions?
Upvotes: 0
Views: 3111
Reputation: 2640
The best way to store the wish list is the database only. You can do that by some ajax.
Or if you dont want to store in database then store it in session. I personally feels that the session will be the best thing.
Upvotes: 1
Reputation: 33865
I am not sure what you mean with I was using javascript cookies, passing the values in the url
, but unless you want to save the wish-list to Db, a cookie will be a good way to go.
Another way would be to execute an ajax-request to the server when you add something to the list, having the server-side code saving the item for you in a session. Then session could then be read when you want to display the list.
Also, HTML5 gives you local storage. Maybe too limited browser support for you, but worth checking out.
Upvotes: 0