Page 1 of 1
How do I kill the session and start a new one?
Posted: Mon Jun 16, 2003 3:43 pm
by andrewcarraway
I am working with a shopping cart application that uses the session_id to identify an order. When the order has been completed, is there a way to begin a new session? Essentially what I need to do is kill the old session_id and start a new one? I have tried using the session_regenerate_id() function, but it does not work on my version of PHP.
Thanks.
Posted: Mon Jun 16, 2003 3:58 pm
by daven
What version of PHP are you running?
If you are using the superglobal $_SESSION[], try the following:
Code: Select all
<?php
session_start();
$_SESSION=array();
session_destroy();
// one of the following two, depending upon your settings
setcookie("SES_NAME","","","/");
setcookie(session_name(),"","","/");
?>
HTH
Posted: Mon Jun 16, 2003 4:35 pm
by andrewcarraway
thanks for the help. I played with it some, and this combination did the trick for me!
session_start();
session_destroy();
setcookie(session_name(),"",0,"/");
Thanks again!