The source of cookies.php (click to demo the file) viewed 1693 times.
If I wrote this code, then it is licensed under the GPL. If someone else wrote it, then please ask them if you want to use the code.
<?php
if ($clear==true) {
setcookie ("Site[items]");
header ("Location: cookies.php");
exit;
}
// They have click a link
if ($add_item==true) {
// If they have more than 1 item
if ($Site[items]==true) {
$new_cookie = "$Site[items]|$add_item";
setcookie ("Site[items]", $new_cookie);
}
else
{
setcookie ("Site[items]", $add_item);
}
// Refresh the page
header ("Location: cookies.php");
exit;
}
echo "You have:<br>";
if ($Site[items]==true) {
$array_items = explode("|", $Site[items]);
$array_items = array_unique ($array_items);
while($output_items = each($array_items))
{
echo "$output_items[value]<br>";
}
}
else
{
echo "no items<br><br>";
}
?>
<br>Books:<br><br>
<a href="?clear=yes_please">Clear the list</a><br><br>
<a href="?add_item=book_cheese">The book of cheese</a><br>
<a href="?add_item=cheese_world">Cheese from around the world</a><br>
<a href="?add_item=humm_cheese">Hummmmm cheese</a><br>
more books from the db etc, etc
If you want to have a look at the source code, chose a file from this list:
To colour code your own PHP paste it here: