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

Users online

Discussion in 'XenForo Development Discussions' started by Zephyr, Nov 30, 2012.

  1. Zephyr

    Zephyr Well-Known Member

  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Since you have access to the XenForo API with that addon you can use code similar to the index page:


    	protected function _getSessionActivityList()
    		$visitor = XenForo_Visitor::getInstance();
    		$sessionModel = $this->getModelFromCache('XenForo_Model_Session');
    		return $sessionModel->getSessionActivityQuickList(
    			array('cutOff' => array('>', $sessionModel->getOnlineStatusTimeout())),
    			($visitor['user_id'] ? $visitor->toArray() : null)
    The session model is what you need to retrieve session information.
  3. Zephyr

    Zephyr Well-Known Member

    Hello Jake :)

    I have this :
    public function userOnlineAction()
    $sessionModel = \XenForo_Model::create('XenForo_Model_Session');
    $userOnline $sessionModel->getSessionActivityQuickList(array(), array());
    $this->render('KynaBoxBundle:Box:MembresEnLigne.html.twig', array('userOnline' => $userOnline));
    This is similar ?
    Whit this code, I have a list of users online.


    Your code does the same thing?


    When I visited the forum:
    Site stats: 1 user online.
    Forum stats: 1 user online.

    When I visited the site (without visiting the forum for a while):
    Site stats: 0 user online.
    Forum stats: 0 user online.

    Site => 0 and not 1 visitor :/
    Should be that people who are on my site are taken into account in the stats.

    And for login user, it's Login model ?
    I can not find the method to connect or even veriffier password and start a session.

  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  5. Zephyr

    Zephyr Well-Known Member

    I already have it, my complete code:

    namespace Kyna\XenforoBundle\Service;
    * Connexion à la base de donnée Xenforo.
    class XenforoIntegration
        public function 
    define('XF_ROOT''/wamp/www/Project/forums'); // set this (absolute path)!
    XF_ROOT '/library/XenForo/Autoloader.php');
    XenForo_Autoloader::getInstance()->setupAutoloader(XF_ROOT '/library');
    XenForo_Application::initialize(XF_ROOT '/library'XF_ROOT);
    // \$userModel = XenForo_Model::create('XenForo_Model_User');
            // \$userinfo = $userModel->getFullUserById($visitor->getUserId());
            // \XenForo_Session::startPublicSession(new \Zend_Controller_Request_Http);
    $xenforoIntegration = new XenforoIntegration;
    I have my XenForo session on my website but the problem does not come from there..
    I can not make myself understood in English, I'll try with pictures ^^

    My website (use xenforo session) :


    My forum :

    Now simulate the arrival of a visitor on the forum.
    The counter is updated :



    Counter site = 1 visitor, forum 1 visitor. Here no problem, everything works fine ;)
    But here's another case :


    Now simulate the arrival of a visitor on the site.


    Problem: Counters remain at 0.
    The site does not send data to the db, XenForo is not informed of visits on the site and does not take into account users online thereof and this is what I'm trying to fix :)

    visitor => forum => db (UserOnline is update).
    visitor => site => db (UserOnline is not update).

    visitor => site/forum => db (getUserOnline is OK but only users who are connected to the forum are included in the user online list).

    It's the problem ^^
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

Share This Page