Problems with user authentication using $_SERVER['PHP_AUTH_

Alles, was PHP betrifft, kann hier besprochen werden.

Problems with user authentication using $_SERVER['PHP_AUTH_

Postby sprinkel » 20. October 2010 18:54

Dear all,

I try to implement user authentication, using $_SERVER['PHP_AUTH_USER'].
On my test environment (my laptop with a WAMP implementation) it works succesfully but on my hosted environment it doesn't work.
Even if I use the code below, the server gives a pop-up, asking a username and password and keeps giving the pop-up.

Do I need to change some seetings on the PHP server or has anybody a clou?

Code: Select all
 
<?php
$username = "1234";
$password = "5678";
if( !isset( $_SERVER['PHP_AUTH_USER'] ) || !isset( $_SERVER['PHP_AUTH_PW'] ))
{
    header("WWW-Authenticate: Basic realm=\"Authentication Server\"");
    header("HTTP/1.0 401 Unauthorized");
    //echo "Login Unsuccesfull";
}
else
{
    echo "Welcome you logged in succesfully!";
}
?>
sprinkel
 
Posts: 16
Joined: 29. August 2009 01:38
Location: Netherlands
XAMPP Version: 5.6.3
Operating System: Windows Vista

Re: Problems with user authentication using $_SERVER['PHP_AUTH_

Postby Altrea » 20. October 2010 19:10

Is your WAMP a XAMPP-Package?

some $_SERVER Variables are only filled if PHP runs as Apache Module, not CGI.
Ask your Hoster which implementation they use.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6946
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: Windows 10 Pro x64

Re: Problems with user authentication using $_SERVER['PHP_AUTH_

Postby sprinkel » 27. October 2010 16:35

Thank you Altrea,

My hosting partner confirmed that PHP is running as a CGI module.
So I will develop my own authentication.

Thanks and regards
sprinkel
 
Posts: 16
Joined: 29. August 2009 01:38
Location: Netherlands
XAMPP Version: 5.6.3
Operating System: Windows Vista


Return to PHP

Who is online

Users browsing this forum: No registered users and 2 guests