I am trying to add 'recent viewed products' feature in my site. So i want to add the products recently watched in cookie. Setting cookie when user go to detail page of the product. So cookie setting code is in detail page. What i am trying
setcookie('recentviews', $productid, time()+3600,'/')
What i need is
recentviews1 =>1
recentviews2 =>5
recentviews3 =>3
OR
recentviews (
[0] => 1,
[1] => 5,
[2] => 3
)
I tried alot of solutions, like setting cookie in loop, but how to know how many views are already set, so I can increment 'recentviews' and set new cookie.