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

how to maintain php project login session in xenforo tab

Discussion in 'XenForo Development Discussions' started by Chirag Dhuvad, Dec 16, 2011.

  1. Chirag Dhuvad

    Chirag Dhuvad New Member

    I am integrating xenforo in core php project.
    i just want my login session should continue in xenforo forum
  2. Mike Tougeron

    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.
  3. Chirag Dhuvad

    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.

Share This Page