只是找到了需要的东西。现在,我可以在 cookies 上存储访问过的产品,然后在它们返回到站点时显示给它们。
// set the cookies
setcookie("product[cookiethree]", "cookiethree");
setcookie("product[cookietwo]", "cookietwo");
setcookie("product[cookieone]", "cookieone");
// after the page reloads, print them out
if (isset($_COOKIE['product'])) {
foreach ($_COOKIE['product'] as $name => $value) {
$name = htmlspecialchars($name);
$value = htmlspecialchars($value);
echo "$name : $value <br />\n";
}
}