[XenAPI] How can I automatically authenticate a user in xenforo from an external script (php)?

Tanki

Member
Hello,

Can you help me please :)?

How can I automatically authenticate a user in xenforo from an external script (php)?

Actually, when a user registers on my site. An account is created on xenforo. I would like to authenticate it automatically on xenforo by cookies.

So, I can retrieve his information:
78e09e3a2739a8c9139e32df42ae05a7.png


I tried to connect it by saving the session, but there are many bugs. The session seems to exist but I do not see myself connected on the dashboard. If I try to connect with another user (user2), I will be connected with the other (User1)

PHP:
$success = setcookie(
            $response['cookie_name'],
            $response['cookie_id'],
            $response['cookie_expiration'],
            $response['cookie_path'],
            $response['cookie_domain'],
            $response['cookie_secure'],
            TRUE
        );

PS : Sorry for my english, I'm from Switzerland.
The code is derived from (cc . @Contex) : https://github.com/Contex/XenAPI/tree/master/net/xenapi/XenAPI/examples/php

Thank you in advance for your help. Have a good day !
Tanki
 
Back,

I looked at it a little and realized the problem :(

A cookie "xf_session" is created when I visit the forum (even as a visitor). When I use the login() method of XenAPI, it will create a "xf_session" too. That's why it does not work.

So, if I run the login() function of XenAPI without visiting the forum previously, then I am connected automatically. And it works.

Do you know how I can correct this? That's pretty important, thank you.

Tanki
 
Back
Top Bottom