PDA

View Full Version : Killing a cookie/session, once order has been placed



Morgenmuffel
27-09-2005, 07:17 PM
Hi All

I want to be able to end a session ( destroy the cookie) once an order has been placed or after 3 days (if no order is placed) ,

This is the code I currently use, it deletes the cookie after 3 days fine,




if(isset($_COOKIE["cartId"]))
{
return $_COOKIE["cartId"];
}
else
{
// There is no cookie set. We will set the cookie and return the value of the users session ID
session_start();
setcookie("cartId", session_id(), time() + ((3600 * 24) * 30));
@mysql_query("insert into cart_cookie(cookie_ID) values('".session_id()."')");
return session_id();



But i don't know how to kill the cookie once an order has been placed.

Cheers Nigel

Morgenmuffel
30-09-2005, 09:39 AM
OK I've found the following code, will this destoy the cookie though



<?php
session_start();
$_SESSION = array();
session_destroy();
?>




or would I have to add something like for my dBase


@mysql_query("delete from cart_cookie where cookie_ID = '".session_id()."'");



but Would this prevent the same session being used again, after all the cookie would still exist with the session id in it