I have a protected portion of a web page. Is there a way I can track who logs in and what time?
Thanks!
Printable View
I have a protected portion of a web page. Is there a way I can track who logs in and what time?
Thanks!
What are you using to log them in? I'd imagine some kind of database, correct? Why can't you store the time/name in there? And if you want to keep a record, simply keep running records of everyone that logs in. (I'd think you'd want to set a limit on the # of records tho)
I am using the 'password protect Directory' feature of my website. I protected a folder and people log in when going to that folder. I was wondering if there was a way to capture which user was logged in?
I don't believe you're going to be able to track them using that method. You're almost certainly going to need to setup a database that can hold times/usernames and you'll have to use a PHP algorithm to log them in.
Thanks. I didnt know if I could just get who was logged in and then I can write that to a database. I didnt know if the username could be passed or not.
Thanks for the help.
With a protected directory, all you have is an access file containing usernames and passwords. When someone tries to login, it checks that htaccess file. I can't personally think of a way of trapping that login without having some program resident on the server, because it's not like you're logging in through a page. You get a pop-up to enter your information. AFAIK, all that is handled through the server.
The username and date is stored in the raw access log, correct? If so, does anyone recommend a program that analyzes access log information.?
I know that Perl can view which user is logged in through an HTACCESS login.. Perl uses $ENV['CURRENT_USER'].
I suggest you try making a test PHP file that looks for the CURRENT_USER enviroment variable.. kinda like this:
PHP Code:<? echo getenv("CURRENT_ENV"); ?>
For a user authenticating through Htaccess (i.e. whenyou say 'protected portion of a web page') and hitting a PHP page, use $_SERVER['PHP_AUTH_USER'] or $HTTP_SERVER_VARS['PHP_AUTH_USER'].
For the date and time, if you store the time in a database, say MySql, you can use "NOW ()" in your SQL statement. Or from PHP, use the "date()" function. For the same format as NOW() 'YYYY-MM-DD HH:MM:SS' in MySql, use date("Y-m-d H:i:s").