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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Powell

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

    [PHP]
    <?php

    class LoginSessionGen erator {

    /**
    * Logout
    *
    * @access public
    */
    function &logout() { // STATIC VOID METHOD
    global $projectFolderN ame, $projectURLPath , $willUseSSL,
    $willAuthentica te, $willBasicAuthe nticate, $projectAcronym ;
    if ($willAuthentic ate || $willBasicAuthe nticate)
    setcookie("$pro jectFolderName" , '', time() - 86400, '/'); // DELETE
    COOKIE
    foreach ($_SESSION as $key => $val) {
    if (preg_match("/^{$projectAcron ym}_/i", $key)) {
    unset($_SESSION[$key]); // DELETE ALL PROJECT SESSION
    VARIABLES
    session_unregis ter("$key"); // DELETE FROM THE SESSION FILE
    REFERENCED BY $PHPSESSID
    }
    }
    if ($willBasicAuth enticate) {
    unset($_SERVER['PHP_AUTH_USER']);
    unset($_SERVER['PHP_AUTH_PW']);
    if (preg_match('/IIS/i', $_SERVER['SERVER_SOFTWAR E']))
    unset($_SERVER['HTTP_AUTHENTIC ATION']);
    }
    header('Pragma: no-cache'); // ENSURE CLIENT-SIDE CACHE
    FLUSHING
    if ($willAuthentic ate && $willUseSSL) {
    $dest = 'https://' . $_SERVER['SERVER_NAME'] .
    "$projectURLPat h/index.php";
    } elseif ($willBasicAuth enticate && $willUseSSL) {
    $dest = 'https://EnterYourUserNa me:EnterPasswor d@' .
    $_SERVER['SERVER_NAME'] . "$projectURLPat h/index.php";
    } elseif ($willAuthentic ate) {
    $dest = 'http://' . $_SERVER['SERVER_NAME'] .
    "$projectURLPat h/index.php";
    } elseif ($willBasicAuth enticate) {
    $dest = 'http://EnterYourUserNa me:EnterPasswor d@' .
    $_SERVER['SERVER_NAME'] . "$projectURLPat h/index.php";
    }
    header("Locatio n: $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
Working...