I need a simple PHP script to record logs of site visitors. No html, no jquery, nothing, just simply to record and to read.
The attributes to record will be:
-Current page URL
-Referer page URL
-Date and Time
-User cookie ID value
-User id if user is registered and logged in
We have approx 5,000 visitors a day and almost 10 pages each. Makes 50,000 rows everyday. I need the database structure in a very speed oriented way.
The script will be put before any code on the page, before the headers are sent. So that you can build your cookie, or check if it exist and then save the log.
The last part of the task will be to make sure the listing of the logs will be fast and reliable. So that I can easily list and navigate:
-Logs by date
-Logs by user
-Logs by visitor by their cookie id
YOU MUST BE AN SQL EXPERT FOR THIS PROJECT. I NEED TO MAKE SURE YOU KNOW HOW TO BUILD FAST PHP+MYSQL APPLICATIONS WITH MORE THAN MILLIONS OF ROWS ON TABLE.
And one tricky part in here is that when a user enters the first time to the website, during recording the first log, PHP will have hard time reading the cookie id, because at the same page log, you give it an ID, send to user browser and then record. When I go through the logs on my current script, I see that a lot of first entries to the page has no cookie ID. You will need to somehow catch them and edit at the second page hit latest.
ALSO LET ME KNOW YOUR THOUGHTS AND SOLUTION BRIEFLY ABOUT THE TRICK I MENTIONED ABOVE. BIDS WITHOUT THIS WILL BE IGNORED.
Hello, I've readed the details. I've done something like this before for my own website. I thinked at the trick, also sent you more details on your inbox.
Regards,
Andy.