PDA

View Full Version : Problems unregistering session variables


bcarl314
10-22-2002, 11:31 AM
I'm creating a site with a logon area, but I'm having some problems unsetting the session variable with my logout.php script. The only way I can unset the variables seems to be to use session_destroy(). But I would rahter not do that as I may need to keep some of the session info intact.

Here's the logout script:


<?php

include("includes/verify.php");
unset($_SESSION["userName"]);
unset($_SESSION["pwd"]);
session_unregister($userName);
session_unregister($pwd);
if(isset($_POST["userName"])) {//ADDED 'cause I thought this might be the problem.
unset($_POST["userName"]);
unset($_POST["pwd"]);
}
session_destroy();//DON'T WANT TO USE THIS
?>
<html><head><title>Login Results</title></head><body>
<?php
if (isset($_SESSION["userName"])) {
print "Successfull login!";
include("includes/html/warning.html");
}
else {
?>
Logout succesfull. Please close all browser windows.<br>
<a href="index.html">Click here to login again.</a>
<?php
}
?>
</body>
</html>


Thanks for the help.

PS: the verify script authenticates the users, but the way it's written here, I should not interfere with the logout script (I think)

sweenster
10-23-2002, 11:47 AM
well looking at the code above you haven't actually opened the session in the first place so maybe this is the problem??

If this is done in the verify.php script then i suggest moving the open session command into this script and maybe that'll work.

The command that opens the session is:

session_start();