0

I currently have the core file Session.php modified a little to keep track of login/logout information and member_ids - create_new_session() for login, destroy() for logout.

I realize that this can be better achieved with an extension using hooks - member_member_login_single after login, member_member_logout after logout.

The issue, though, is with the logout hook the system doesn't pass along any data (documentation), so there's no way for us to know the member_id of the user who just logged out.

Is there a way to accomplish this at all aside from modifying core files? I already have a hacky solution (editing core files), so I'm looking for the "right" way to do this.

1 Answer 1

1

Although the hook doesn't provide any information you can use, you could do a query on the exp_members table where ip_address is equal to the users ip, and sort the results by last_activity descending. Logging out should record the timestamp into the last_activity field and the ip address is updated every time a member logs in. As a result, this should then allow you to get the relevant data for that member to use in your tracking. But yes, definitely use hooks instead of hacking core files :)

1
  • Definitely less hacky than what I'm currently doing, as this would allow me to exclusively use an extension. I'll give it a shot and report back if it works or not. Thanks for thinking out of the box on this one! Mar 2, 2016 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.