PDA

View Full Version : How to Pass user authentication information from htaccess/htpasswd to PHP



bahattab
05-12-2009, 06:59 PM
Passing user authentication information to PHP




The best way to protect your directory is with htaccess/htpasswd protection. But you may also want to pass the user information to your php scripts so you can do custom processing based on who logged in. You can retrieve the current authenticated user with one php line. Put this in the target script in the protected directory (used in the script after authentication).

You can download (http://tips-scripts.com/authentication.txt) this script as a .txt file. Remember to rename the file as a .php file.






- - Start Script Here - -
<?php
$user = $_SERVER['REMOTE_USER'];
?>
- - End Script Here - -



http://tips-scripts.com/authentication