[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 |