Forum Moderators: coopster
Warning: session_destroy() [function.session-destroy]: Session object destruction failed in D:\wamp\www\index2.php on line 25
25 row:
session_destroy();
My code:
if(isset($_GET['Logout'])) {
$query = 'UPDATE user SET
time = "0000:00:00:00:00:00" WHERE user = "'.$_SESSION['name'].'"';
$sql = mysql_query($query, $db_link) or die("Error"); session_destroy();
echo "<meta http-equiv='refresh' content='1;URL=index.php'>";
exit;
}
echo '<a href=?Logout>Logout</a>';
Does not understand what it's bad.
Thanks in advance for the help
this is mandatory before use sessions (if you are getting $_SESSION['name']) is already done.
session_start();
first destroy all variables used
session_unset();
$_SESSION = array();
if use a cookie for propagate destroy it too
setcookie(session_name(), '');
finally
session_destroy();
NomikOS: first destroy all variables used
session_unset();
$_SESSION = array();
PHP Manual - session_destroy() [uk2.php.net]
Note: Only use session_unset() for older deprecated code that does not use $_SESSION.
Lolalola: When I am using one session all right.
But now I have 4 sessions
Do you mean 4 variables within one session? Rather than 4 entirely separate sessions?
$_SESSION['level']
$_SESSION['pass']
$_SESSION['name']
$_SESSION['favorite']
check you are using session_start() (as mentioned above)
test to see whether the session exists
if (isset($_SESSION)) {
session_destroy();
}
the great lengths to wipe all possibility of data is not really required, it used to be and some sites that are oddly configured make extra lengths sometimes necessary. In general a session_destroy will do it. You can dump the session before and after to see what's left.
for the paranoid, set each var individually to blank, then destroy and then enforce good garbage collection and short logout times, I wouldn't set the cookie, just me maybe but it isn't necessary.