Re: Detecting authenticated user in PHP script
| From: | Brian Clark | Date: | Thu, 10 Aug 2000 10:38:53 +0000 |
| Subject: | Re: Detecting authenticated user in PHP script | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-11116@lists.php.net to get a copy of this message | ||
Francisco M. Marzoa Alonso wrote:
Hi again, I've have a directory which has an .htaccess file, the auth. function is working right but now... I need to know the login of the user that has access to the page within a PHP script, how can i do it?$GLOBALS['PHP_AUTH_USER'] and $GLOBALS['PHP_AUTH_PW'] In conjunction with an existing authentication system (Apache's), or you can use WWW-Authenticate headers. if(!$krause->Authenticate()) {
header('WWW-authenticate: basic realm="Administration"');
header('HTTP/1.0 401 Unauthorized');
print $krause->error_msg;
exit();
}
Anyway, the primary objetive is to redir. the user browser to a page depending on the login name, if you've a better solution...You could store the logins in a database table, or you could read a flat-file on disk and compare them to $GLOBALS['PHP_AUTH_USER'] and $GLOBALS['PHP_AUTH_PW'] Brian