Topic: Yet another integration issue - setting the cookie outside of punBB
Having spent the better part of the day trying various things from the forum here, thought I would finally break down and ask. I have a members site which is using sessions. What I am trying to do is during the checklogin.php, which checks the existing members DB and adds the session info for the rest of the site...also set the cookies for punBB. End result is when the member is in the members section, they can just click a link to the forum and be already logged in.
Here is the code I have running, unsuccessfully, right now although it looks like it should work:
//set forum cookies
$cookie_name = 'punbb_cookie';
$cookie_domain = '';
$cookie_path = '/';
$cookie_secure = 0;
$cookie_seed = '######';
$username = addslashes(trim($myusername));
$resultforum = mysql_query("SELECT * FROM TABLE WHERE username LIKE '$username'");
$rowforum = mysql_fetch_array($resultforum);
$userid = $rowforum['id'];
$passhash = $rowforum['password'];
$expire = time() + 31536000;
if (version_compare(PHP_VERSION, '5.2.0', '>=')) {
setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$passhash))), $expire, $cookie_path, $cookie_domain, $cookie_secure, true);
} else {
setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$passhash))), $expire, $cookie_path.'; HttpOnly', $cookie_domain, $cookie_secure);
}
If anyone has any ideas or advice it would be appreciated.