I am wanting to display items to the user by using cookies, I have run into an issue where when wanting to delete a single cookie from the list nothing happens. For each record that is displayed to the user there will be a delete button. Currently when the delete button is clicked the cookie value does not get set to a blank value. For initial testing the only cookie that will be set to blank is cookievalue1
if (isset($_REQUEST['attempt'])) {
if (isset($_POST['sound1'])) {
$intwoMonth = 60 * 60 * 24 * 60 + time();
setcookie("cookievalue1","",$intwoMonth);
}
}
$i = 1;
$x = 4;
$username = "Username";
$orderno = "0353627";
$item1 = "Bread";
$price1 = "$50";
$item2 = "Cheese";
$price2 = "$46";
$subtotal = "$96";
$tax = "5%";
$total = "$100";
$var = NULL;
$cookiearray = array($username,$orderno,$item1,$price1,$item2,$price2,$subtotal,$tax,$total);
print_r($cookiearray); print '<br></br>'; print '<br></br>';
while ($i < $x) {
$cookiearray1 = serialize($cookiearray);
setcookie("cookievalue" . $i, $cookiearray1, time()+3600);
print '<br></br>';
$var = unserialize($cookiearray1);
$var2 = unserialize($cook1);
print $var2[$i];
print '<br></br>';print '<br></br>';
print '
<body>
<form action="cookieandarray6.php?attempt" method="post"/>
<input type="delete" name="sound1" value="sound1"<br><br>
<input type="submit" value="Delete"/>
</form>
</body>';
print '<br></br>';print '<br></br>';
$i = $i + 1;
}
?>