XF 2.0 XF:SessionActivity


Well-known member
Outside of XenForo 2, the getOnlineUsersList is pulled. If the user logins to XenForo from outside XF 2 and hasn't browsed then the repository isn't showing that the user is in fact logged into the site. Once the account browses to XenForo 2 installation then the getOnlineUsersList is updated to show the user.

This is the code that I'm using.

/** @var \XF\Repository\SessionActivity $activityRepo */
$activityRepo = \XF::app()->repository('XF:SessionActivity');
$onlineCount = $activityRepo->getOnlineCounts();
$onlineUserList = $activityRepo->getOnlineUsersList(50);
Pulling the SessionActivity in XenForo 1 worked fine; that is, once the person logged in then they were shown on the list. They never had to browse to the XF installation.

Am I doing something wrong in my reasoning? Should I try to use something else besides the repository?


XenForo developer
Staff member
Unless you hit an actual XF "public" page, your session activity won't be updated. If you want that to happen elsewhere, you'd need to do it manually.

See XF\Pub\Controller\AbstractController::updateSessionActivity().


Well-known member
Perfect !

Added the following line:
   \XF::visitor()->user_id, \XF::app()->request->getIp(),
   '', '', array(''), 'valid',