PHP unset cookie and setcookie not responding

58 Views Asked by At

I hope someone can help me with the following.

Im trying to delete a cookie that was created with jquery. So when clicked on a form (action = code/delete.php), it gets an id ($x). and then selects the cookie and should delete it. But nothing is happening, it doesnt get deleted.

I checked echo $x and thats ok

    //File: Cart/code/delete.php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);

require_once("../../config.php");
session_start();

$x = $_GET['id'];
$x = preg_replace("[^0-9]", "", $x);
if (isset($_COOKIE['cart_'.$x])) {
    unset($_COOKIE['cart_'.$x]);
    setcookie('cart_'.$x, '', time()-3600); 
    $succesMsg = "<div class='alartSucces'>Product met succes verwijderd.</div>";
    $_SESSION['succes'] = $succesMsg;
    header("Location: ".DEFAULT_URL."/cart/");
}
0

There are 0 best solutions below