Page 1 of 1

generate log file(or track user)

Posted: Mon Aug 30, 2010 1:45 am
by simran10101
I need to create logs of each user for eg when user enter into session(after login) I want to track its each activity.(where he click) . plz send your valuable suggestions to perform this task .

Re: generate log file(or track user)

Posted: Mon Aug 30, 2010 4:46 am
by phpcip28
If you do NOT use codeigniter this is not as easy , BUT easy enough.

So what you have to do is create a database table called visitors
it would have the following fields

ID - primary key, unique key of INTEGER type.
user_id - this should be the user_id that you are storing inside the $_SESSION.
page_visited - of type VARCHAR 250 chars
time_visited - of type DATETIME

And on your each page in the header somewhere do this

Code: Select all

if($_SESSION['user_id']){

    //Now the user is logged in, so just insert all his actions in the database table you've just created.

    mysql_query("INSERT INTO visitors (......................) VALUES (..................)");
}
Maybe also add an IP address field to that table and so forth.

Hope this makes sense.