I am setting cookies on one page, let’s say, ‘register.php’. Then I am reading those cookies on another page (‘login.php’) and unsetting the cookies (deleting them) on this page. Everything works except for the last part: I am NOT able to delete the cookies. Would anyone help me?
Step1 (‘register.php’ page) — Setting the cookies:
[code=php]
$errors = array() // Suppose, this array is full with ‘errors’…
if(!empty($errors)) {
foreach($errors as $name => $value) {
setcookie(“errors[$name]”,$value,0,’/someDirectory/’);
}
Step2 (‘login.php’ page) — Reading and deleting the cookies:
[code=php]
if(isset($_COOKIE[‘errors’])) {
foreach($_COOKIE[‘errors’] as $name => $value) {
print $name . ” ” . $value;
setcookie(‘errors[$name]’,”,1); // This line does NOT work.
}
}
As I said above, I am able to set and read cookies but I am not able to delete them. Please, help!