your cookie is set as "product" so, in PHP you use $_COOKIE['product'] to retrieve the cookie that you saved.
Hi everyone,
I am creating a shopping cart using cookies. The item is post method form which can be $cart = $_REQUEST['item']. I am trying to create an array of requested items using
<?php
if ($cart) {
$cart .= ',' .$_REQUEST['item'];
} else {
$cart = $_REQUEST['item'];
}
setcookie( "product", $cart,time()+86400);
?>
But not able to retrieve data using the following so the get items from the database.
<?php
if ($cart) {
$items = explode(',',$cart);
foreach ($items as $item) {
echo $item;
}
}
?>
Can anybody give me the solutions?
your cookie is set as "product" so, in PHP you use $_COOKIE['product'] to retrieve the cookie that you saved.
"The generation of random numbers is too important to be left to chance."