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

#1
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:


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
 
#2
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
 
Top