how to maintain php project login session in xenforo tab

Mike Tougeron

Well-known member
In your index.php (and maybe admin.php) after you create an instance of the XenForo_FrontController but before you $fc->run() it you'll need to log the user into XenForo. If you've validated the main site's session and have found the appropriate xenforo user_id you can call XenForo_Model::create('XenForo_Model_User')->setUserRememberCookie($userId, $auth); to set the login cookie. Once that is done, XenForo_Session should pick everything up appropriately and treat the user as logged in. It'll set the xf_session cookie based on the user you logged in via that method.

This isn't a perfect method but it should get the job done for you.

As a side note, be sure to clear all the xenforo cookies when you log the user out on your main site or else you'll end up with mixed session states.

Chirag Dhuvad

New member
we have a folder structure where in the index.php, login.php and register.php of our core php module are outside in the root and we have a forum folder where all the xenforo forum has been instatlled. Can you suggest me a method so the I can check whether a user is logged in or not via a script that runs in my login.php which is outside the forum folder and when a user logs in he automatically gets logged in into xenforo. i.e. I want to login into xenforo through my login script externally into my login.php page.