newbie basic realm protection - why don't the input usr/pass stick?

From: Date: Tue, 07 Dec 2010 23:51:38 +0000
Subject: newbie basic realm protection - why don't the input usr/pass stick?
Groups: php.general 
Request: Send a blank email to php-general+get-309899@lists.php.net to get a copy of this message
Hi everyone I am hacking my way through something unrelated to this post.. but needed to stop and (real quick) pass-protect a page to use it to run some quick (*admin-only*) scripts on a shared host. ..and I see now how poor is my understanding of what seems like basic stuff. As a start for my quick understanding to pass protect a page, I used the "Example #6 Basic HTTP Authentication example", from here: http://www.php.net/manual/en/features.http-auth.php ..which is just this: <?php if (!isset($_SERVER['PHP_AUTH_USER'])) {
    header('WWW-Authenticate: Basic realm="My Realm"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Text to send if user hits Cancel button';
    exit;
} else {
    echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
    echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
} ?> ..and no matter what i type in the authentication dialogue that pops up.. then after I submit it.. it just keeps looping forever popping up the dialogue.. I.e. I never get past the authenticate dialogue to see this line executed: echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>"; What am I missing? Thanks for your bothering to help with this, ------------ Govinda

« previous php.general (#309899) next »