XF 1.5 Access user object from outside XF

SpecialK

Well-known member
I am bootstrapping XF using the following code, which is working fine. However, when I try to access the Visitor object, it's showing up as a guest user essentially, with a user ID of 0, even though I'm logged in to the forums. Is this a cookie issue (Live site at site.com, dev at staging.site.com)? If so, is there any way to work around it?

PHP:
$startTime = microtime(true);
$fileDir = '/home/site/public';

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);

// Not required if you are not using any of the preloaded data
//$dependencies = new XenForo_Dependencies_Public();
//$dependencies->preLoadData();

XenForo_Session::startPublicSession();

  $visitor = XenForo_Visitor::getInstance();
  print_r($visitor);
 
Spoiler..it was a cookie issue. I updated library/config.php to change the cookie domain, cleared my cookies, logged out and back in and it's working beautifully now.
 
Top Bottom