Page 1 of 1

Http authentication, Win 2k, IIS 5 - Mac IE problem

Posted: Tue Jun 29, 2004 2:51 am
by hairyjim
Hi all,

I have the following code that works fine for IE on windowsand also with Safari & Netscape on Mac.

The problem is IE on the mac. If I were to navigate to a page with the below code it asks for authentication which is good. If I were to follow a link to another page also using the same code it asks to reauthenticate.

Im scratching my head with this one. Could someone please advise.

Code: Select all

<html>
<?
/* Check for values in $PHP_AUTH_USER and $PHP_AUTH_PW */ 

if ((!isset($_SERVER&#1111;'PHP_AUTH_USER'])) || (!isset($_SERVER&#1111;'PHP_AUTH_PW']))) &#123;


    /* No values: send headers causing dialog box to appear */
    header('WWW-Authenticate: Basic realm="Private"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Authorization Required.';
    exit; 

&#125; else if ((isset($_SERVER&#1111;'PHP_AUTH_USER'])) && (isset($_SERVER&#1111;'PHP_AUTH_PW'])))&#123; 

    /* Values contain some values, so check to see if theyre correct */ 

    if (($_SERVER&#1111;'PHP_AUTH_USER'] != "myuser") || ($_SERVER&#1111;'PHP_AUTH_PW'] != "mypassword")) &#123;
       /* If either the username entered is incorrect, or the password entered is incorrect, send the headers causing dialog box to appear */
       header('WWW-Authenticate: Basic realm="Private"');
       header('HTTP/1.0 401 Unauthorized');
       echo 'Authorization Required.';
       exit;
    &#125; else if (($_SERVER&#1111;'PHP_AUTH_USER'] == "myuser") || ($_SERVER&#1111;'PHP_AUTH_PW'] == "mypassword")) &#123;
       /* if both values are correct, print success message */

//My web page omitted from here for readability.

     &#125;
&#125;
?>
</html>