I'm developing a media bookmarking site and am looking for a way to remember whether a user has bookmarked an item (without having to go to the DB every page load to check).
I haven't used PHP sessions before, but I'm thinking they would do the trick.
Would it make sense to do an initial DB call when the user logs in, grab all the items that a user has bookmarked and save an array of all the item ids to the user session?
Then when a page is loaded, for each of the 100 items on the page it would check whether that item's ID is in the session array (so we know whether to display the "bookmark" button or an indicator that they've already bookmarked it).
Just want to make sure this is a right strategy, or if there is a better way. Would this work fine even if there are 10,000 ids in the array?