phpmysqllogging

How to log user actions with php and mysql?


I'm working on my CMS and I want it to log activities by users and other admins. For example: when new user registers or admin makes a new news post -> update last activity.

I want to know what is the best and easiest way.


Solution

  • You can then write a reporting tool that gives your admins access to those logged activities, you can filter by user, time and activity types.

    In my log-framework, I specially mark activities which could be seen as malicious actions and assign them different numeric threat-values. If the sum of a user's thread-value reaches a certain threshold I log-out the user.

    Ideally if you write an Application, you write your infrastructure code like logging at the very beginning and then use it in all your business logic code later.

    Edit for cleanup:

    Over time you may collect lots of records in that table. Depending on your requirements you could do different things.