Forum Moderators: coopster

Message Too Old, No Replies

sessions/cookies - logging out

need help logging out of a session via cookies...

         

legacy411

4:24 am on Mar 29, 2005 (gmt 0)



i need help..i have a script that won't logout...here's the logout code:

<?php
$login_real_path = "./";
include($login_real_path . "common.php");

$db->sql = "SELECT * FROM ".$prefix."_config";
$result = $db->query($db->sql);

while($row = $db->fetch($result)) {
$domain = $row['site_url'];
$script_path = $row['script_path'];
}
if($HTTP_GET_VARS['logmeout'] == 'yes') {
setcookie("loged","no",time()-3700, $script_path, $domain);
setcookie("username","",time()-3700, $script_path, $domain);
setcookie("user_level","",time()-3700, $script_path, $domain);
$session = uniqid('logout_');
if(!session_is_registered('user_level')) {
header("Location: index.php");
}
} else {
include($login_real_path . 'includes/page_header.php');
$display = "<center><font class=\"text\">Are you sure you want to logout?</font></center><br><center><a href=\"logout.php?logmeout=yes\">Yes</a> ¦ <a href=\"javascript:history.back()\">No</a></center>";
$template->getFile(array(
'logout_body' => 'logout_body.tpl')
);
$template->addVar("logout_body", array(
'DISPLAY' => $display)
);
$template->parse("logout_body");
include($login_real_path . 'includes/page_footer.php');
}
?>

[edited by: jatar_k at 5:17 pm (utc) on Mar. 29, 2005]
[edit reason] removed links [/edit]

ironik

5:05 am on Mar 29, 2005 (gmt 0)

10+ Year Member



If you are using sessions you can use:

session_destroy();

That will terminate the session and destroy the data. You might also want to use session_regenerate_id() if you need to re-assign a new session to the user (sometimes it seems to hang onto a session id).

coopster

10:46 pm on Mar 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, legacy411.

You might also want to make sure your server is populating the $HTTP_GET_VARS array. Have you tried dumping that variable to make sure data is there?