Session will not destroy
Posted: Tue Jul 16, 2002 11:35 am
I admit I'm a relative newbie to PHP although I have years of experience in other languages. The problem is I have a logout that is supposed to destroy the session completely yet right afterward I go to start a session and it gives me the message:
Notice: Constant sid already defined in /home/finale/public_html/login.php on line 39
Why are there still remnants remaining from the previous session?!
The situation is the newest recommended php on apache running Linux. Cookies are being used for the sessions but I even try to kill the cookie manually. Below is the code:
The main file has this code:
// If logout then close the current session
if (isset($_SESSION['Logout'])) {
unset($_SESSION['Logout']);
Logout($SessionName, $_SESSION['Name'], $_SESSION['StartDate']);
// Create new session
session_name($SessionName);
session_start();
}
and the function Logout looks like this:
function Logout(&$SessionName, &$Name, &$StartDate) {
//remove the local session
// Update login entry in Audit Login to have logout time
$EndDate=date('Y-m-d H-i-s');
$sql = "UPDATE AuditLogin SET EndDate='$EndDate' WHERE (Name='$Name') AND (StartDate='$StartDate')";
DoUpdate($sql);
// set player status to offline
$sql = "UPDATE Players Set Online=0 WHERE Name='$Name'";
DoUpdate($sql);
// unset($Name);
// unset($StartDate);
// session_unset();
session_name($SessionName);
session_start();
// Unset all of the session variables.
$_SESSION = array();
// Destroy the session.
session_destroy();
//remove the client session
// setcookie($SessionName,"",0,"/");
setcookie($SessionName);
}
Yes, I know that passing by reference is not required here
The message is for the main file on the line session_start().
I have tried the commented and uncommented setcookie.
The cookie session destruction code is exactly from the php help. Am I missing something here besides my sanity?!
Notice: Constant sid already defined in /home/finale/public_html/login.php on line 39
Why are there still remnants remaining from the previous session?!
The situation is the newest recommended php on apache running Linux. Cookies are being used for the sessions but I even try to kill the cookie manually. Below is the code:
The main file has this code:
// If logout then close the current session
if (isset($_SESSION['Logout'])) {
unset($_SESSION['Logout']);
Logout($SessionName, $_SESSION['Name'], $_SESSION['StartDate']);
// Create new session
session_name($SessionName);
session_start();
}
and the function Logout looks like this:
function Logout(&$SessionName, &$Name, &$StartDate) {
//remove the local session
// Update login entry in Audit Login to have logout time
$EndDate=date('Y-m-d H-i-s');
$sql = "UPDATE AuditLogin SET EndDate='$EndDate' WHERE (Name='$Name') AND (StartDate='$StartDate')";
DoUpdate($sql);
// set player status to offline
$sql = "UPDATE Players Set Online=0 WHERE Name='$Name'";
DoUpdate($sql);
// unset($Name);
// unset($StartDate);
// session_unset();
session_name($SessionName);
session_start();
// Unset all of the session variables.
$_SESSION = array();
// Destroy the session.
session_destroy();
//remove the client session
// setcookie($SessionName,"",0,"/");
setcookie($SessionName);
}
Yes, I know that passing by reference is not required here
The message is for the main file on the line session_start().
I have tried the commented and uncommented setcookie.
The cookie session destruction code is exactly from the php help. Am I missing something here besides my sanity?!