0

I have a forum using phpbb on my website. Now I would like to be able to authenticate the user with the forum login and password.

After some researches, I found this:

<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
?>

But it doesn't work. Do you have any idea why?

2
  • Welcome to StackOverflow. What do you mean by "it doesn't work" ? I don't understand what you're asking for. Do you want to test if user is connected and redirect it if he is not identify ? (Which version are you using ?) Mar 17, 2017 at 13:12
  • Hi @alexandre-t, the problem is that when I include the common.php file, all go well, but when I add $user->session_begin(), I have an error saying that the user variable and the session_begin() function doesn't exist.
    – Yvo
    Mar 17, 2017 at 17:20

1 Answer 1

0

It seems that you're using version 3.1 or 3.2. Since 3.1, Phpbb is using Symfony framework and MVC pattern. If you want to to create a new page, you have to create a new route and a new controller.

If you do not know how to create a new extension page, you should have a look on this tutorial

Create a new extension could be difficult, if you do not understand the MVC patterns. So I encourage you to use the skeleton extension. After some easy configuration steps, it will create for you the route and the controller.

If you only want to test login in an existing page, you have to use event. At this point the global session $user and permissions $auth, do NOT exist yet. If you need to use the user object (f.e. to include language files) or need to check permissions, please use the core.user_setup event instead!

3
  • Thanks, I'm gonna test that
    – Yvo
    Mar 18, 2017 at 19:59
  • I don't really understand how to use all this, but it look like it's made to be used by the forum, and I want to login from a webpage outside of this forum.
    – Yvo
    Mar 19, 2017 at 11:58
  • I don't really understand what do you mean by : I want to connect from a webpage outside of this forum. Do you want to recode the login form and the login controller ? Mar 20, 2017 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.