MyBB Community Forums

Full Version: Using myBB accounts in my own script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 :

<?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 !
if you want only check user logged in or not you can do this .

if($mybb->user['uid'])
{
echo "user logged in";
}






note : if you want more complex code , I am at your service as non-free programmer.


Telegram : @MostafaShiraali
Discord : MostafaShiraali#7754(mostafashiraali)