Hello,
You can use HTTP_AUTH without .htaccess file. It is very easy. You can
use like following example on your web site.:)
<?php
if ( ( !isset( $_SERVER['PHP_AUTH_USER'] )) ||
(!isset($_SERVER['PHP_AUTH_PW'])) || (
$_SERVER['PHP_AUTH_USER'] != 'username' ) || (
$_SERVER['PHP_AUTH_PW'] != 'password' ) )
{
header( 'WWW-Authenticate: Basic realm="My Private Area"' );
header( 'HTTP/1.0 401 Unauthorized' );
echo "<h1>Authorization Required.</h1>";
exit;
}
else
{
session_start();
session_register("sessionpass");
$_SESSION["sessionpass"]="1";
header( 'Location: http://www.somehostname.com/filename.php');
}
?>
In this example, If the user and password are right, You can set
$_SESSION["sessionpass"]="1" and then you can control this variable
beginning of the PHP file like following.
Begining of the filename.php
<?
session_start();
if (!session_is_registered ('sessionpass'))
{
echo "<h1>Authorization Required.</h1>";
exit;
}
.........
.........
.........
.........
?>
"Mike van Hoof" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello,
>
> I've got a really strange problem, and hope this is the right list to
> post to.
>
> I got a website with a login, which uses a .htaccess file for
> autentication. That part works like a charm. But when i want to read the
> loggin details with PHP, the variable $_SERVER['|PHP_AUTH_USER'] isn't
> set (in the directory where i logged into)
>
> when i go a directory back, and view a phpinfo() there i see
> |$_SERVER['|PHP_AUTH_USER']|| is set, so i do a phpinfo() in the
> directory with the .htaccess and it is gone.
>
> Had anyone ever had experience with this, because i can't find a solution.
>
> - Mike|
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php