Topic: External login / cookie / authentication questions
We are working on integrating PunBB into one of our major sites. We don't need to worry about account CRUD, this is already working. The only piece we have not been able to complete is the login script to allow people that login on our main site to appear logged in on the punbb forums.
Forums are located in www.domain.com/forums/. $forumUser['PunbbUser'] is a database row from the punbb_users db table. $password is set above this block of code, but it is the value passed from the login form.
Here is our integration script:
$forum_user = $forumUser['PunbbUser']; // used to spoof punbb into thinking we are logged in
if(!defined('FORUM_ROOT')) {
define('FORUM_ROOT', 'forums/');
}
require_once FORUM_ROOT.'config.php';
require_once FORUM_ROOT.'include/functions.php';
($hook = get_hook('in_start')) ? eval($hook) : null;
$userId = $forumUser['PunbbUser']['id'];
$salt = $forumUser['PunbbUser']['salt'];
$hash = forum_hash($password, $salt);
$saveLogin = 0;
$expire = ($saveLogin) ? time() + 1209600 : time() + $forum_config['o_timeout_visit'];
forum_setcookie($cookie_name, base64_encode($userId.'|'.$hash.'|'.$expire.'|'.sha1($salt.$hash.forum_hash($expire, $salt))), $expire);
This actually generates a cookie. I have compared all the vars going into forum_setcookie() and they are 100% the same as those used in /forums/login.php (ignoring the time difference of $expires).
Can someone please point out the detail that we are missing. I would owe the owner of the correct answer a beer, for sure.
Thanks.