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

External login to XenForo from a PHP site

Discussion in 'XenForo Pre-Sales Questions' started by aqua-calc, Jun 11, 2014.

  1. aqua-calc

    aqua-calc New Member


    Is there a documented way to implement "login" to XenForo from a PHP site?

    I've searched the forum but found only one original post without any reply.

    Thank you!
  2. Liam W

    Liam W Well-Known Member

    What do you mean by login would be the first question.

    You could easily post the relevant auth details to the login script, get the session ID and set the cookie yourself, however I don't think that's what you want to do.
  3. aqua-calc

    aqua-calc New Member

    I'd like to be able to access the logged-in user name, group name, etc... from within my own PHP web site.

    And to be able to provide login and logout links and/or custom web pages from that same PHP website.

    Thank you!
  4. Liam W

    Liam W Well-Known Member

    Why? Can't you implement your own website into XenForo? It would make things 1000x easier :)

    I guess the easiest way to do it would be to make XenForo take cookies from the same domain as the main site (I'm already assuming it's on the same domain, so that's no too easy).

    You could either link to the XF login form, or simply request the login details, check them yourself with the XF classes and set the cookie, or get the login details and post them to the XenForo login, then set the cookies you get back to the users browser.

    You could then include the XenForo system in your PHP, and use it to get the relevant details.

    aqua-calc likes this.
  5. aqua-calc

    aqua-calc New Member

    Thank you Liam!

    Unfortunately, I don't have access to XF classes since I don't own an XF license. I'm thinking of switching away from phpBB forum, and am looking for an alternative.

    Thank you again.
  6. Jeremy

    Jeremy XenForo Moderator Staff Member

    Yes, you can access XenForo data from outside of XenForo.
  7. aqua-calc

    aqua-calc New Member


    Is there a documented API interface?

    Thank you,

  8. Jeremy

    Jeremy XenForo Moderator Staff Member

    No, but the files do have comments and it is laid out in a manner that makes it very easy to pick up. Plus, the community is extremely helpful in helping out.
    wedgar and aqua-calc like this.
  9. aqua-calc

    aqua-calc New Member

    Thank you again!
  10. feldon30

    feldon30 Well-Known Member

    I can tell you that we went through this on our PHP/CodeIgniter application and it took over 30 hours of development to get external logins working with XenForo, and still, accessing the AdminCP requires a kludgy workarond.

    Here's my thread about what it took to get this working:

    and here's my Suggestion thread asking for XenForo to add external login support:

    XenForo needs to provide a way for a third party script to say "This user is logged in". Not, here's the user's password, let's juggle hashing algorithms and go ten rounds. Just, this user (e-mail address) is logged in so get over it!

    SMF, a free forum, provides exactly this functionality through a third party script. We got external logins completely working in less than 2 hours. However we wanted to use a professional forum and so endured rewriting all this in XenForo.
    Dan Allen, otto and aqua-calc like this.
  11. aqua-calc

    aqua-calc New Member

    I'm looking to migrate to a professional board as well.

    Thank you for referencing the above two threads -- I will review them carefully.

    At present I'm using phpBB -- (a few years ago) it took less than an hour to read a relevant phpBB thread and to implement code into my website with which to get user status, name, etc...

    I wish that XF would offer a development or a trial license, so I could try to implement new or test existing code first.



Share This Page