I handle last visited products on a cookie array. Assume it is called visited_product.
When a user visit a product i push product id to $_COOKIE["visited_product"]
. Then I explode this array by "-" character.
Then I reach to db for product info with these ids
Example:
$_COOKIE["visited_products"] = "12-45-67-89-3-6-9"
and my final array is = {9,6,3,89,67,45,12}
// as you can see I reversed array for descending time order.
When I request to mysql with this array it returs products in ascending order or descending order by product_id
. How can I return product info like array's order?
I don't want to add time value to cookie. It is possible with this structure?
my mysql query like:
SELECT * FROM products WHERE product_id = 9 OR product_id = 6 OR ...