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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.