I am trying to write a plugin that will set an identical session cookie for another area of my website after a successful MyBB login. Everything works exactly how I want, except it will not grab the correct UID from the session; instead it is returning "0".
Here is the relevant section of my plugin code:
The result creates a cookie called "my_session" with the following value:
0+ABCDE+2b9463c2ea380080735787d18af3c1db
I have been able to confirm that $sessionid is correct with each login, but instead of "1" (which is my UID), it keeps grabbing "0". This is really bizarre because when I check the database, the session value is a match for my UID (1). There are no sessions logged for UID "0" because you must be logged-in to view the page.
Any help would be appreciated!
Here is the relevant section of my plugin code:
function myplugin_datahandler_login_complete_end()
{
global $mybb, $db, $session;
$cookie_name = "my_session";
$sessionid = $session->sid;
$myuser = $mybb->user['uid'];
$cookie_value = "$myuser ABCDE $sessionid";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/");
}
The result creates a cookie called "my_session" with the following value:
0+ABCDE+2b9463c2ea380080735787d18af3c1db
I have been able to confirm that $sessionid is correct with each login, but instead of "1" (which is my UID), it keeps grabbing "0". This is really bizarre because when I check the database, the session value is a match for my UID (1). There are no sessions logged for UID "0" because you must be logged-in to view the page.
Any help would be appreciated!