We have a website https://shycomics.fr/ associated with a PhpBB3.3 forum.
This website gets user variable with the classic code and allows to know if a user is connected or not :
Code: Select all
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : $pathPhpBB;
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$request->enable_super_globals();
But we'd like to migrate the site on Symfony 5. Of course, this kind of code can't work anymore because it conflits with Symfony variables.
So I check directly on phpbb\session.php forum side to see how sessions work. I use the the session_begin function to help me, it's something like that I wrote on my website :
Code: Select all
if($request->cookies->get('phpbb3_shyco_sid') !== null or $request->cookies->get('phpbb3_shyco_u') !== null)
{
$this->cookie_data['u'] = $request->cookies->get('phpbb3_shyco_u');
$this->cookie_data['k'] = $request->cookies->get('phpbb3_shyco_k');
$this->session_id = $request->cookies->get('phpbb3_shyco_sid');
if (!empty($this->session_id))
{
$userPhpbb = $this->phpbbUserRepository->getPhpbbUser($this->session_id);
...
Code: Select all
$sql = 'SELECT u.*, s.*
FROM ' . SESSIONS_TABLE . ' s, ' . USERS_TABLE . " u
WHERE s.session_id = '" . $db->sql_escape($this->session_id) . "'
AND u.user_id = s.session_user_id";
It seems that this behavior is done here on phpbb\session.php, on session_create function :
Code: Select all
$sql_ary['session_id'] = (string) $this->session_id;
$sql_ary['session_page'] = (string) substr($this->page['page'], 0, 199);
$sql_ary['session_forum_id'] = $this->page['forum'];
$sql = 'INSERT INTO ' . SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
Thanks