Throught cPanel, I password protected a directory (for 4 users). In my php page, I have a variable called
$aid. Is there a way to set a value to $aid depending on who is logging in to the directory?
explain what exactly is the difficulty! depending on the way you authencicate users something like if($cookie=='Mark') { $aid=1; } elseif(.....
See I don't know how to set the IF condition:
if (????) { $aid = "VALUE"; }
What is the ??? since the authentication is done through HTTP... or whatver it's called.
$SERVER['PHP_AUTH_USER'] ----> to check username $SERVER['PHP_AUTH_PW'] ---> to check password
Hmm, so what does this do? Check the username/password entered to enter the protected directory?
shawon22's solution will work but only for php that is used as apache module
If you are running php as cgi then it won't work
GM
Okay so tell me if this is good:
if($_SERVER['PHP_AUTH_USER'] == 'johnny' && $_SERVER['PHP_AUTH_PW'] == 'doey') { $aid = '1'; } elseif(...and so on...
hmm ya
for more information check this page out http://php.planetmirror.com/manual/en/print/features.http-auth.php