Hello All,
I need to be able to record the Date/Time that a registered user logs in and out of Joomla (along with some other details such as Name). I know that there is a field 'lastvisitDate' that effectively is the login Date/Time, but I need to trap the logout Date/Time as well.
Can someone please tell me, apart from attempting to write a Mambot/Plugin which doesn't seem to support the events, where in the core code I can insert some code to write these details to a new table?
Can someone please clarify for Joomla 1.0.13 if Mambots support any 'onuserlogin' or 'onuserlogout' USER events?
Thank you in anticipation,
Ed Cox
J! 1.0.13 Login and Logout 'logging' Question
Moderators: tjay, seadap, Rogue4ngel, matthewhayashida
- edward_cox
- Joomla! Apprentice
- Posts: 6
- Joined: Thu Aug 30, 2007 3:05 am
Re: J! 1.0.13 Login and Logout 'logging' Question
I just came to the forum tonight looking for the same thing. Actually I would be very happy if there was a module or component that already did this. Or, if somebody could point me to where in the system joomla writes logs for who is logging in and logging out!
Thanks, Sean Carney
Thanks, Sean Carney
- edward_cox
- Joomla! Apprentice
- Posts: 6
- Joined: Thu Aug 30, 2007 3:05 am
Re: J! 1.0.13 Login and Logout 'logging' Question
Hi Sean,
as I had to get this done in a rush I ended up with a hack solution. The Community Builder (CB) comprofiler.php code was my answer and specifically allowed me to trap a user login and logout (except for a session timeout) writing the data to a new table.
If it's of any use to you I would be happy to share the hacked code (all care, no responsibility and all that). Just let me know.
in a nutshell:
I added a new table: jos_users_access
fields : id, userid, logdate, name, branch, login, logout, event
(your mileage may vary - please modify to suit)
within
directly before
This ensures that the 'login' Event is trapped directly onAfterLogin via the event system.
Then for the logout code:
Directly before is called.. ..
Which ensures the logout data is trapped before all the data is lost.
Anyway, it's a hack - and I would much prefer that this was a Mambot/Module Extension/Plugin.
Hope that's of some assistance. (and thanks to those that were able to assist me!)
Regards,
Ed Cox
as I had to get this done in a rush I ended up with a hack solution. The Community Builder (CB) comprofiler.php code was my answer and specifically allowed me to trap a user login and logout (except for a session timeout) writing the data to a new table.
If it's of any use to you I would be happy to share the hacked code (all care, no responsibility and all that). Just let me know.
in a nutshell:
I added a new table: jos_users_access
fields : id, userid, logdate, name, branch, login, logout, event
(your mileage may vary - please modify to suit)
within
Code: Select all
function login()
directly before
Code: Select all
$_PLUGINS->trigger( 'onAfterLogin', array($row, true));
Code: Select all
$com_query = "SELECT cb_location FROM #__comprofiler WHERE id = ".$row->id;
$database->setQuery($com_query);
$where = $database->loadResult();
$logdate = date('y/m/d g:i:s');
$xzquery = "INSERT INTO #__users_access SET userid = '$row->id', logdate = '$logdate', name = '$row->name', branch = '$where', login = '$logdate', logout = '', event = 'login'";
$database->setquery($xzquery);
$database->query();
This ensures that the 'login' Event is trapped directly onAfterLogin via the event system.
Then for the logout code:
Directly before
Code: Select all
$mainframe->logout();
Code: Select all
$com_query = "SELECT cb_location FROM #__comprofiler WHERE id = ".$my->id;
$_CB_database->setQuery($com_query);
$where = $_CB_database->loadResult();
$logdate = date('y/m/d g:i:s');
$query = "INSERT INTO #__users_access SET userid = '$row->id', logdate = '$logdate', name = '$row->name', branch = '$where', login = '', logout = '$logdate', event = 'logout'";
$_CB_database->setquery($query);
$_CB_database->query();
Which ensures the logout data is trapped before all the data is lost.
Anyway, it's a hack - and I would much prefer that this was a Mambot/Module Extension/Plugin.
Hope that's of some assistance. (and thanks to those that were able to assist me!)
Regards,
Ed Cox
Re: J! 1.0.13 Login and Logout 'logging' Question
Hi Ed,
That looks great. Unfortunately I am not literate enough to know how to do that. But, it looks nice. I sure wish somebody had a module already. :-)
I will consider this more but don't think I will be brave enough to try it. :-)
Sean
That looks great. Unfortunately I am not literate enough to know how to do that. But, it looks nice. I sure wish somebody had a module already. :-)
I will consider this more but don't think I will be brave enough to try it. :-)
Sean