Cannot grab correct UID from hook
#1
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:

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!
Reply


Messages In This Thread
Cannot grab correct UID from hook - by Dexie - 2015-09-23, 09:11 PM
RE: Cannot grab correct UID from hook - by SvePu - 2015-09-24, 10:01 AM
RE: Cannot grab correct UID from hook - by Dexie - 2015-09-24, 08:42 PM
RE: Cannot grab correct UID from hook - by RateU - 2015-09-24, 08:53 PM
RE: Cannot grab correct UID from hook - by Dexie - 2015-09-24, 11:38 PM
RE: Cannot grab correct UID from hook - by RateU - 2015-09-25, 12:25 AM
RE: Cannot grab correct UID from hook - by Shade - 2015-09-25, 10:04 AM

Forum Jump:


Users browsing this thread: 3 Guest(s)