我已经将phpbb3论坛集成到我现有的网站上.
我已经能够使我的注册过程也将用户添加到phpbb数据库中.
现在,我正面临一个问题,即当我登录我的网站时,我试图让用户自动登录论坛.
这里有人这样做过吗?我在Google上找不到任何相关内容,因为所有帖子似乎都在谈论'phpbb外部网页'以及如何在其他网页上使用phpbb会话.然而,我想要做的是仅在会员登录我的网站时启动登录,并且按照我在谷歌上找到的教程将让我的用户登录我的论坛时登录我的网站(这是另一种方式).
谢谢
<?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']];
}
}
?>
Run Code Online (Sandbox Code Playgroud)