HTTP authentication problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

HTTP authentication problem

Post by Gente »

Hi everyone

I have a script with HTTP authentication. It works perfectly on my local server but when I deployed it to another server I met following situation.
Every time when I pressed "OK" Login/Password window appears again not depending from data I inputed. I tried to debug it and in the end I took the simple example from PHP manual:

Code: Select all

<?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>";
  }
?>
Result is the same. What can be wrong?

Thanks for you suggestions.
Post Reply