User login/logout and activity statistics

  • Application Version OJS 3.2.x

  • Description of issue
    I’m supporting a user who is using OJS as part of grant funded/proposed work. Some of the grant will involve training participants on OJS, and the grant PIs will need to be able to report the amount of time each participant spent on OJS and the kinds of activities they engaged in.
    I’m trying to get all the data they need (ideally) out of the OJS database rather than doing something with apache logs. I see the sessions table is populated with user ids and first action/last action timestamps, but I’m having a hard time finding information on how that table is populated/updated.

  • Steps you took leading up to the issue
    My plan is to make a script that will extract data from the event_log and sessions tables about the users of interest and transform it into some useful stats as needed. From trial and error, it looks like when a user logs out, the entry that represented that session is deleted. Other than creating a TRIGGER for that table on DELETE that copies that row somewhere else, is there any other way to get a ‘time-spent-on-platform’ measurement from the database?

  • What you tried to resolve the issue
    I looked through the developer docs and didn’t find any leads.

Hi @IOPNdev,

OJS extends the PHP session management toolset – in particular, see lib/pkp/classes/session/SessionManager.inc.php, and the call there to session_set_save_handler. You should be able to accomplish what you’re looking for by adding a few lines of logging code there, or to lib/pkp/classes/session/SessionDAO.inc.php, which it relies upon to map session data to the database.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Thanks! That is exactly what I need.

1 Like