By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,391 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,391 IT Pros & Developers. It's quick & easy.

Logout method fails to.. do anything (cookies/sessions/redirection)

P: n/a
[PHP]
<?php

class LoginSessionGenerator {

/**
* Logout
*
* @access public
*/
function &logout() { // STATIC VOID METHOD
global $projectFolderName, $projectURLPath, $willUseSSL,
$willAuthenticate, $willBasicAuthenticate, $projectAcronym;
if ($willAuthenticate || $willBasicAuthenticate)
setcookie("$projectFolderName", '', time() - 86400, '/'); // DELETE
COOKIE
foreach ($_SESSION as $key => $val) {
if (preg_match("/^{$projectAcronym}_/i", $key)) {
unset($_SESSION[$key]); // DELETE ALL PROJECT SESSION
VARIABLES
session_unregister("$key"); // DELETE FROM THE SESSION FILE
REFERENCED BY $PHPSESSID
}
}
if ($willBasicAuthenticate) {
unset($_SERVER['PHP_AUTH_USER']);
unset($_SERVER['PHP_AUTH_PW']);
if (preg_match('/IIS/i', $_SERVER['SERVER_SOFTWARE']))
unset($_SERVER['HTTP_AUTHENTICATION']);
}
header('Pragma: no-cache'); // ENSURE CLIENT-SIDE CACHE
FLUSHING
if ($willAuthenticate && $willUseSSL) {
$dest = 'https://' . $_SERVER['SERVER_NAME'] .
"$projectURLPath/index.php";
} elseif ($willBasicAuthenticate && $willUseSSL) {
$dest = 'https://EnterYourUserName:EnterPassword@' .
$_SERVER['SERVER_NAME'] . "$projectURLPath/index.php";
} elseif ($willAuthenticate) {
$dest = 'http://' . $_SERVER['SERVER_NAME'] .
"$projectURLPath/index.php";
} elseif ($willBasicAuthenticate) {
$dest = 'http://EnterYourUserName:EnterPassword@' .
$_SERVER['SERVER_NAME'] . "$projectURLPath/index.php";
}
header("Location: $dest"); // DEFAULT REDIRECT TO MAIN PAGE
exit();
}

}

?>
[/PHP]

The following class method is evoked to ensure a user is logged out by
deleting their cookie, deleting session variables and redirecting
them.

Everything worked beautifully while using Mozilla Firefox 0.6, but the
moment I tried using the same app with MSIE it did absolutely nothing;
it did not delete cookie, session variables, it didn't even redirect!

Please help I'm stuck here!

Thanx
Phil
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.