News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

SMF 2 integration (integrate_verify_user hook) - session data is different

Started by latheesan, October 15, 2014, 04:15:15 AM

Previous topic - Next topic

latheesan

I am trying to use the http://wiki.simplemachines.org/smf/Integration_hooks#integrate_verify_user

So, I have created a file called my_integrate_verify_user in the forum folder, which has the following code:

function my_integrate_verify_user()
{
    var_dump($_SESSION); exit();
}


Then I inserted the following entries into smf_settings table:

INSERT INTO smf_settings (variable, value) VALUES
('integrate_pre_include', '/path/to/my_integrate_verify_user.php'),
('integrate_verify_user', 'my_integrate_verify_user');


Before I visit my forum, I load my site and login into it, which sets the following session data (to be used in the smf integration hook later):

$_SESSION['IsLoggedIn'] = true;
$_SESSION['LoggedInUser'] = 'hello123'; // Test


Now, when I visit the SMF forum (that is running my above hook), I see the following session data from SMF:



I am not seeing the session data (IsLoggedIn and LoggedInUser) that was set by my site (outside of the smf).

P.s the urls are:


If I visit my site again - I am still logged in. However on the session var_dump in the hook, i don't see my session data. Any idea why this is? Some kind of scope issue?

Kindred

that is correct.

SMF sets its own session data - which means that it destroys any previously set session.
So, essentially, you can't do what you are trying to do...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

You're not supposed to touch $_SESSION with that hook anyway.

The function - as described in that guide which I originally wrote - is not about injecting values into $_SESSION. You are supposed to return a number to it to indicate which user is logged in. E.g. if you're using some other cookie or some other thing to authenticate the user, you need only return the user's id from that function and SMF will do everything else for you.

Advertisement: