bcoffin Posted September 8, 2008 Share Posted September 8, 2008 I have an authentication system in place for my site. I need to have it automatically log users into a phpbb installation (release 3). Found this code: <?php define('IN_PHPBB', true); $phpbb_root_path = './'; //Path to forum $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup('ucp'); if($user->data['is_registered']) { echo "Welcome " . $user->data['username']; //User is already logged in } else if(isset($_POST['login'])) { $username = request_var('username', '', true); $password = request_var('password', '', true); $autologin = (!empty($_POST['autologin'])) ? true : false; $result = $auth->login($username, $password, $autologin); if ($result['status'] == LOGIN_SUCCESS) { //User was successfully logged into phpBB $redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx"); // append/replace SID $redirect = reapply_sid($redirect); meta_refresh(1, $redirect); trigger_error('LOGIN_REDIRECT'); } else { echo 'Bad Login'; //User's login failed } } else { echo '<form action="index.php" method="post"> <label for="username">Username:</label><input type="text" name="username" /><br /> <label for="password">Password:</label><input type="password" name="password" /><br /> <input type="hidden" name="redirect" value="index.php" /> <label for="autologin">Automatic login:</label><input type="checkbox" name="autologin" id="autologin" class="checkbox" /> <input type="submit" value="login" name="login" /> </form>'; } ?> At this link: http://www.phpbb.com/community/viewtopic.php?f=71&t=983935 And when I test it, the PHPBB auth system return SUCCESS, then redirects to a forum page. That forum page shows the user as not-logged-in. Any help appreciated. Link to comment https://forums.phpfreaks.com/topic/123344-integrating-existing-auth-system-with-phpbb3/ Share on other sites More sharing options...
bcoffin Posted September 9, 2008 Author Share Posted September 9, 2008 I'm sorry folks.. I was probably doing something silly, but this EXACT script works just fine. Link to comment https://forums.phpfreaks.com/topic/123344-integrating-existing-auth-system-with-phpbb3/#findComment-637113 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.