phpBB3 auto-login

送分小仙女□ 提交于 2019-11-30 05:14:05

问题


I've integrated a phpbb3 forum to my already existing website.

I've been able to make my registration process add the user to the phpbb db as well.

Now i'm facing a problem where I am trying to get the user to auto-login to the forum when he logs in to my website.

Have anyone here done that? I can't find anything relevant on Google as all posts seem to talk about 'phpbb external webpages' and how you can use phpbb sessions on other webpages. however what i'm trying to do is to initiate a login only when the member logs in to my website, and following the tutorials i found on google will let my users log in to my site when they log in to my forum (which is the other way around).

Thanks


回答1:


<?php
    define('IN_PHPBB', true);
    $phpbb_root_path = '../phpBB3/'; //the path to your phpbb relative to this script
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include("../phpBB3/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', 'john');
    $password = request_var('password', '123');

    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']];
      }
    }
?>


来源:https://stackoverflow.com/questions/5092340/phpbb3-auto-login

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!