我可以使用一个集成的登录系统在我的网站和phpBB3中登录。但是我无法注销...我尝试了销毁会话或使用->logout();
我登录的身份是:
$phpBBusername = $_SESSION['username'];
$phpBBpassword = $_SESSION['pswd'];
$result = $auth->login($phpBBusername, $phpBBpassword);
<?php
define('IN_PHPBB', true);
$phpbb_root_path = '../phpBB3/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include("../phpBB3/common.php");
$user->session_kill();
echo 'Logged out successfully!';
?>
public function myphpbb_logout()
{
define('IN_PHPBB', true);
global $phpEx, $user, $db, $config, $cache, $template;
$phpEx = 'php';
$phpbb_root_path = ('.\/forum\/');
require_once($phpbb_root_path . 'common.php');
set_include_path(get_include_path.PATH_SEPARATOR.$phpbb_root_path);
//logout user
$user->session_kill();
$user->session_begin();
$user->session_kill();
}
请注意,您需要两次终止会话 :)
<?php
// Unset all of the session variables.
$_SESSION = array();
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
// Finally, destroy the session.
session_destroy();
?>
这应该可以满足你的需求。