Chris.E
Member
Hi Guys,
I have some code that I am using to log in users via my website using PHP. It seems to work, but the problem is that after hitting the code below, the first time they visit the forum it doesnt recognize them as logged in. If they refresh the page once more they are then logged in.
The code I am running is part of the XENForoSDK:
$userModel = XenForo_Model::create('XenForo_Model_User');
// Set cookie if needed
if($remember) {
$userModel->setUserRememberCookie($user);
}
// Log IP
XenForo_Model_Ip::log($user, 'user', $user, 'login');
// delete current session
$userModel->deleteSessionActivity(0, $_SERVER['REMOTE_ADDR']);
$this->getSession()->changeUserId($user);
$this->getVisitor()->setup($user);
$user = $this->getUser();
return $user;
I have some code that I am using to log in users via my website using PHP. It seems to work, but the problem is that after hitting the code below, the first time they visit the forum it doesnt recognize them as logged in. If they refresh the page once more they are then logged in.
The code I am running is part of the XENForoSDK:
$userModel = XenForo_Model::create('XenForo_Model_User');
// Set cookie if needed
if($remember) {
$userModel->setUserRememberCookie($user);
}
// Log IP
XenForo_Model_Ip::log($user, 'user', $user, 'login');
// delete current session
$userModel->deleteSessionActivity(0, $_SERVER['REMOTE_ADDR']);
$this->getSession()->changeUserId($user);
$this->getVisitor()->setup($user);
$user = $this->getUser();
return $user;