0

I've asked this question on phpBB.com but still have not got an answer back. I'm trying to create an external login script as many other others do. I've searchd over phpBB.com and SO without a answer that suffices my problem.

I've borrowed this question from This SO post. I get the message "You're logged in", but when I visit my board I'm not logged in. I'm not sure exactly whats wrong. I apologize if this has been posted somewhere else before.

<?php
    define('IN_PHPBB', true);
    $phpbb_root_path = './'; //the path to your phpbb relative to this script
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include("./common.php"); ////the path to your phpbb relative to this script
    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();

    $username = request_var('username', 'Username');
    $password = request_var('password', 'Password');

    if(isset($username) && isset($password))
    {
      $result=$auth->login($username, $password, true);
      if ($result['status'] == LOGIN_SUCCESS) {
        echo "You're logged in";
      } else {
        echo $user->lang[$result['error_msg']];
      }
    }
?>

This code is posted in the root directory of my forums, so the phpBB root path is correct. I am running 3.0.12, fresh install, no MODs installed.

Community
  • 1
  • 1
Ozair Patel
  • 1,658
  • 1
  • 12
  • 17
  • Can you check your cookies to see if an auth cookie for phpbb is being set – Krimson May 08 '14 at 21:44
  • @Krimson ah I just checked and it isn't being set, I do have cookies enabled on my web server, how can I go about fixing that issue? – Ozair Patel May 08 '14 at 22:15
  • I'm not sure I understand what you're trying to do to be honest. Is this script supposed to log somebody in on a browser? – Ruby May 08 '14 at 22:18
  • @RubyMewMew No, the script simply starts a user session on the phpBB board. – Ozair Patel May 08 '14 at 22:19
  • Ah I'm sorry my bad I completely misunderstood the question, allow me to re-read it. – Ruby May 08 '14 at 22:19
  • @OPatel please check my new answer that should have sorted your problem, found the function you can use to log the user in! – Ruby May 08 '14 at 22:31

0 Answers0