How to check user work history

Hi to all,

Hello friends i am rajesh, I just start working on PHP. i get a assignment in which i had to track user work.

Means when user login. after that.
What he did (which page he visited and what he download etc etc) untill logout?

I could not able to find the process that how to start. and what all i have to do for this?

If any one of you did this type of work earlier than pls guide me how to do…

Thanks in Advance.

Regards
Rajesh
[email protected]

The simplest way of doing it would be to set a variable each page with the page’s name, then when the user goes to that page, run an update query that - if not empty - adds its location to the list, along with any other data you want, like date and time or possibly the user’s ip.

another method is to scan the log files for a matching IP address. The logs have a timestamp and the page visited listed along with other useful stuff. It sound complex but it really isn’t bad at all and your not burdening a database each time a visitor loads a page. The IP can be grabbed using the session vars. This information is being recorded anyway, might as well put it to use.

If you want to go down this road I can assist.

You could do it that way, but if you move servers or something happens with that file, you’re screwed. And its not really that bad, its 1 query per page. If you don’t have to record each and every time the user visits that page, you could run a select query before the update.

Log files are easily downloadable and are backed up with the rest of server files. If you ‘loose’ a log file, you’ve got bigger problems…

One ding to the mysql db per page doesn’t seem bad at all, until your site gets popular. The accepted method for doing this is using the log files. That’s why they’re there and that what the big boys do.

So what about those big forums that have thousands of users every day? Forums themselves run at least 4 queries in a single page, so that’d be 400 if 100 people went on at exactly the same time, and yet it still loads in 1second or less. Don’t underestimate PHP and how fast it can do queries.

I agree that a MySQL log would be the best way to do this. If you want to track every movement, just insert new data into a database. If you just want last action, just update an existing row.
Log Files have a security issue where if you have sensitive information in them, and someone unauthorized gets access, you’re kinda screwed. It also makes it harder to tack just 1 person where MySQL has the ability to decide what you see.

You also don’t have to load a file that could be several thousand lines long into memory just to find a single line. Plus, they don’t always track php memu sites properly.

I run several reports from data in my log file. One checks for landing on my ‘you are not authorized to view that page’ page. If I see some has landed there I grab the ip and scan the rest of the log to see what else this person is doing. I also log this ip separately and retest to see if this person is continuing to monkey with my site in the future. if problems continue I block that ip.

Log files get automatically rolled over to prevent them from getting too large.

I only run my reports on my log files about once a week, ok sometimes every two or three weeks if I’m busy… I’m usually busy!

The log files are created wether you use them or not. It seems redundant to add the same information into a database too.

log files are used automatically depending what is in the apache settings. with Mysql u can focus more directly on what YOU want to show. And you’re way is very time consuming. Say you do 1 log per 2MB of data, and yuo go through 20MB/day of logs. Thats 10 files a day you have to scan. Obviously you’re not using this type of setting but if you want to look through all your logs for a specific IP it’s going to take time, compared to a mysql query which takes seconds.

my largest log file is 986.43kb. I can open, scan for visitors who have been redirected to my ‘not allowed’ page obtain their ip and rescan the file again and print all entries for that ip. This takes, well I’ll call it a second, it’s pretty much instantaneously. I’ve been doing this for years and it is not an overly burdensome task.

There is a proper answer to this but only the teacher who assign the homework can be the judge. I’m afraid this another thread where we’re here splitting hairs while the original poster has disappeared… The poster used the term ‘history’ which usually implies using the log files, which are also know as history.

Either way can be used, its just a matter of what you’re trying to accomplish with it.

Sponsor our Newsletter | Privacy Policy | Terms of Service