I am using a cookie to identify the owner of a shopping cart.
The cookie is set on entry page and passed on to a class for farious cart operations.
The cookie is set with the known code:
Code: Select all
setcookie("name", $value, time()+(60*60*24*14), "/", "www.myDomain.com");The function itself is called from code running in the background checking for valid pament.
Code: Select all
mysql_query("DELETE FROM ".$dbpraefix."cart WHERE user_id = ".$cart_user."");
setcookie("name", $value, time()-(60*60*24*14), "/", "www.myDomain.com"); // actual code, I also tried to set time value to 1
Code: Select all
if(isset($_COOKIE['test']))
{
echo "<br /><br />";
echo $_COOKIE['test'];
echo "<br /><br />";
}
if(isset($_COOKIE['test']) && isset($_POST['delete']))
{
setcookie("test", "testcookie", time()-(3600*25), "/");
}
if(!isset($_COOKIE['test']) && isset($_POST['set']))
{
setcookie("test", "testcookie", time()+(3600*25), "/");
}
?>
<form action="cookie-test.php" method="post">
<input type="submit" name="set" id="set" value="Set Cookie" />
<input type="submit" name="delete" id="delete" value="Delete Cookie" />
</form>
If anybody does know a solution for that I would be very glad to hear.
Thanks a lot