Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use PHP to detect which htaccess user signed in?

Tags:

php

.htaccess

I'm constructing an upload so people I know can send me files securely, and with ease. But I want to design it just so, that when one of my friends sign in with their sign-in (it's going to an .htaccess login), I can establish that in PHP and log their file into a database associated with their account.

In short, I need PHP to be able to detect who is signed in so I can pass that data to a database.

Is there any possible way of doing that?

like image 760
nkcmr Avatar asked Jan 24 '11 21:01

nkcmr


3 Answers

You should be able to get the user name the user signed in with from the $_SERVER['REMOTE_USER'] variable after they've successfully signed in.

like image 124
Michael Irigoyen Avatar answered Nov 05 '22 14:11

Michael Irigoyen


You'd want $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] to retrieve the username and password, assuming you mean a regular "basic authentication" login, as done by Require valid-user settings in .htaccess.

more details here.

like image 7
Marc B Avatar answered Nov 05 '22 13:11

Marc B


Something that worked for me:

$_SERVER['REDIRECT_REMOTE_USER']

Please try the above. In general, one can do "print_r($_SERVER)" and hunt out the parameter one is looking for.

like image 7
Onkar Parmar Avatar answered Nov 05 '22 14:11

Onkar Parmar