Hi
Id like a cookie to store a customers recent items viewed.
Im doing this to set the cookie:
And then in my list Ive got this:PHP Code:setcookie("viewed", "", time()+3600000);
PHP Code:if (isset($_COOKIE["viewed"])) {
foreach ($_COOKIE["viewed"] as $name => $value)
{
echo "$name : $value <br />";
}
} else {
echo "no cookies";
}
If a user clicks on an item it is meant to add the URL of the item to the cookie array list (after making sure its not already there). Im doing this:
PHP Code:if (isset($_COOKIE["viewed"]))
setcookie("viewed[".$mid."]","$mid");
}
Unfortunately I'm getting the echo statement 'no cookies' so I reckon the setCookie function is wrong, but am I going about this the right way? Ive searched online and not found anything to specifically explain using cookies and then pushing items to the array list.
Can you help?




Reply With Quote