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

separate php page

Discussion in 'XenForo Development Discussions' started by TerminalAddict, Jan 14, 2011.

  1. TerminalAddict

    TerminalAddict Active Member

    in an entirely separate php that I have (test.php) in a folder above my xf installation I have the following code (which I found on this forum):
    $startTime = microtime(true);
    $fileDir = dirname(__FILE__);
    $fileDir = $fileDir . '/community';
    require($fileDir . '/library/XenForo/Autoloader.php');
    XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
    XenForo_Application::initialize($fileDir . '/library', $fileDir);
    XenForo_Application::set('page_start_time', $startTime);
    $visitor = XenForo_Visitor::getInstance();
    $user_id = $visitor->getUserId();
    $username = $visitor->get('username');
    $email = $visitor->get('email');
    echo "$user_id $username $email";
    it always returns 0 (zero) even though I am logged into the forum at /community/
    I have also confirmed that the object(XenForo_Visitor) has the following:
      array(40) {
        string(0) ""
    can anyone help please?
  2. Shadab

    Shadab Well-Known Member

  3. TerminalAddict

    TerminalAddict Active Member

Share This Page