470,870 Members | 1,516 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,870 developers. It's quick & easy.

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

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

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Phil Powell | last post: by
reply views Thread by konsu | last post: by
8 posts views Thread by Harlin Seritt | last post: by
4 posts views Thread by ad | last post: by
25 posts views Thread by crescent_au | last post: by
18 posts views Thread by Vic Spainhower | last post: by
10 posts views Thread by DavidPr | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.