Welcome Guest, Not a member yet? Register   Sign In
Weird behavior of htauth and $this->input->server('PHP_AUTH_USER', True);
#1

[eluser]Unknown[/eluser]
Hi All
Thank you for great software and a great community!

I am working on a small htauth-controller.
The below simple code is placed in one of my controllers.

The following code works...:
Code:
public function authenticate()
{
  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 $this->input->server('PHP_AUTH_USER', True)."\n";
   echo $this->input->server('PHP_AUTH_PW', True)."\n";

  }
}

...And correctly returns:
mortenlp
testP4sw0rd

However the following code:
Code:
public function authenticate()
{
  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 $this->input->server('PHP_AUTH_USER', True)."\n";
   echo $this->input->server('PHP_AUTH_PW', True)."\n";

  }
}
Returns:
"Text to send if user hits Cancel button"

The requests are exactly identical.

Do you know what this might be caused by?
Best wishes
Morten Pedersen
Denmark






Theme © iAndrew 2016 - Forum software by © MyBB