1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Updating 'last_activity'

Discussion in 'Troubleshooting and Problems' started by Hardcore, Aug 26, 2012.

  1. Hardcore

    Hardcore Active Member

    Just some quick questions on the 'last_activity' row in the 'xf_user' table.

    I'm using XF for user authentication and have non-XF pages with user submitted content. When users login to our non-XF pages they're redirected to them by the XF login system after successfully logging in. Some users may never even visit the forum as a result. As such, I'm noticing that their 'last_activity' is not being updated.
    • Does simply logging into XF not trigger an update?
    • When is 'last_activity' updated? What activities trigger an update?
    • Could I simply create custom code to update a user's 'last_activity' on my non-XF pages?
    Thanks in advance ...
     
  2. Hardcore

    Hardcore Active Member

    I'm updating the 'xf_user' table now, which works for a few things that I'm doing, but it looks like 'xf_session_activity' is tied into this on a XF visual level too. Would love to be able to for my non-XF pages to trigger activity on XF; last active on user views/profiles, members online now, etc.

    Looks like it's time to do some code digging ...
     
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The user last activities are updated by the hourly cron:

    XenForo_CronEntry_CleanUp

    The cron is called in the footer on XenForo pages.

    When the last activities are updated it gets the activity info from the session records.

    The session is setup on each page load in the controller:

    XenForo_Controller::_setupSession

    And the controller also updates session activity after each dispatch:

    XenForo_Controller::postDispatch

    In the case of external pages you probably aren't using a XenForo controller (aside from when you login). That means no activity updates after the login action unless you visit a XenForo page.

    Hopefully this helps.
     
    tenants likes this.
  4. Hardcore

    Hardcore Active Member

    Thanks, Jake. It does from an understanding point of view.

    In the end I just created a quick function that updates xf_user's last_activity and inserts/updates an entry in xf_session_activity; using XenForo_ControllerPublic_Index as a default. Does the trick, for now.
     
    tenants likes this.

Share This Page