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

Updating 'last_activity'


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 ...


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 ...

Jake Bunce

XenForo moderator
Staff member
The user last activities are updated by the hourly cron:


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:


And the controller also updates session activity after each dispatch:


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.


Active member
Hopefully this helps.
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.