header() sometimes fails, sometimes works, same url

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • comp.lang.php

    #1

    header() sometimes fails, sometimes works, same url

    <?
    header('Pragma: no-cache'); // ENSURE CLIENT-SIDE CACHE FLUSHING
    $url = "$projectURLPat h/index.php";
    if ($_REQUEST['logoutMsg']) $url .= '?logoutMsg='.
    urlencode($_REQ UEST['logoutMsg']);
    if ($willAuthentic ate && $willUseSSL) {
    $dest = 'https://' . $_SERVER['SERVER_NAME'] . $url;
    } elseif ($willBasicAuth enticate && $willUseSSL) {
    $dest = 'https://EnterYourUserNa me:EnterPasswor d@' .
    $_SERVER['SERVER_NAME'] . $url;
    } elseif ($willAuthentic ate) {
    $dest = 'http://' . $_SERVER['SERVER_NAME'] . $url;
    } elseif ($willBasicAuth enticate) {
    $dest = 'http://EnterYourUserNa me:EnterPasswor d@' .
    $_SERVER['SERVER_NAME'] . $url;
    }
    header("Locatio n: $dest"); // DEFAULT REDIRECT TO MAIN PAGE
    exit();

    ?>

    This code scriptlet will allow for redirection to dynamically relocate
    to another URL. However, for some bizarre reason, it will not redirect
    anywhere; it just dies (no warnings, no errors, no notices, no
    nothing!), however, if you refresh your browser, the redirected page
    appears, sometimes after 1, 2, 3 tries. Then sometimes it redirects
    with no problems at all.

    I tried closing my browser, logging out, refreshing everything,
    deleting cache/history.. to no avail.

    This only started occurring the moment I used my SessionHandler class
    to relocate session files elsewhere due to a business requirement - the
    moment I removed SessionHandler, this redirection weirdness occurred
    and no amount of debugging seems to be able to solve the problem.

    Ideas? Help?

    Phil

Working...