2024-03-01, 02:25 PM
Hi gang,
So haven't done any php in decades (php3 lol), I would like to create a tool that uses myBB accounts to log in. How do I catch the current session (and if not send back people to the forum homepage to log) ?
I asked chatgpt, but it doesn't seem to be doing anything :
Thanks for the help !
So haven't done any php in decades (php3 lol), I would like to create a tool that uses myBB accounts to log in. How do I catch the current session (and if not send back people to the forum homepage to log) ?
I asked chatgpt, but it doesn't seem to be doing anything :
<?php
define('IN_MYBB', 1);
require_once 'global.php';
$session = $mybb->session;
$session->start();
// Get user ID
$uid = $session->get('uid');
// Get username
$username = $session->get('username');
echo $username;
// Check if user is logged in
if($session->is_set('uid')) {
echo "Welcome, $username!";
} else {
echo "Please log in to access this page.";
}
?>
Thanks for the help !