Hi guys I'm trying to build a form wich allow me to create cookies, and I want to be able to delete them as well, to do that there is an option at the bottom of the form that send me to my file call see_cookies.php that generate another form with some php to create a loop that will go through al the $_COOKIE array and print every checkbox with the information. Also some submit buttons with allows my to delete all or the ones I choose, but I'm not able to delete them. Could anyone help me please.
this is the code for see_cookies.php:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ver::Cookies</title>
</head>
<body>
<h1>Cookies en el sevidor</h1>
<form action="delete_cookies.php" method="post">
<?php
foreach ($_COOKIE as $nombre => $contenido) {
print <<<pinta
<input type="checkbox" name="nombre_cookie[]" value="$nombre"/>$nombre($contenido)<br>
pinta;
}
?>
<input type="submit" value="Delete" name="delete">
<input type="submit" value="Delete_All" name="delete_all">
</form>
</body>
</html>
this is the code for delete_cookie.php
<?php
function delete_cookie($nombre){
setcookie($nombre," ",-10);
}
if(isset($_POST["delete_all"])){
foreach ($_COOKIE as $nombre => $contenido ) {
delete_cookie($nombre);
}
}elseif(isset($_POST["delete"])){
foreach ($_POST["nombre_cookie"] as $key => $contenido) {
delete_cookie($contenido);
}
}
?>