[SOLVED]Problem deleting a cookie
Posted: Tue Jan 25, 2011 6:15 am
After 1 week resaerch without a result somebody here might have a solution for the cookie deleting problem.
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:
After the user finalized the purchase the cart is empty and the cookie need to be deleted which is done in a class function.
The function itself is called from code running in the background checking for valid pament.
Creating a test page like the following, setting and deleting the cookie works.
Also setting the path to any different then "/" doesn't work since the cookie has to be avilable in the page directory where it was created, in the class directory where all the processing takes place and in the payment processor where the cart owner need to be identyfied using various methods just to be sure.
If anybody does know a solution for that I would be very glad to hear.
Thanks a lot
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