Not Solved Cannot access Global.php
#1
Not Solved
Hello,

I am trying to get the current username. I am logged in, however, when I use this code:

define('IN_MYBB', 1);
        require_once "./forums/global.php";
        
        $username = $mybb->user['username'];

$username is empty.

I have no errors and the file is working because when I load my forums, its all fine.

Anyone have an idea why it isn't working? I've tried this code:

global $mybb;

above:

$username = $mybb->user['username'];

Also but still nothing?

EDIT: http://connectiongaming.net76.net/ is the page it is on and http://connectiongaming.net76.net/forums is where my forums are held.
Reply
#2
Not Solved
(2015-10-10, 12:10 PM)Nineteh Wrote: Hello,

I am trying to get the current username. I am logged in, however, when I use this code:

define('IN_MYBB', 1);
        require_once "./forums/global.php";
        
        $username = $mybb->user['username'];

$username is empty.

I have no errors and the file is working because when I load my forums, its all fine.

Anyone have an idea why it isn't working? I've tried this code:

global $mybb;

above:

$username = $mybb->user['username'];

Also but still nothing?

EDIT: http://connectiongaming.net76.net/ is the page it is on and http://connectiongaming.net76.net/forums is where my forums are held.

Adjust your cookie settings, set "Cookie Path" to "/" instead of "/forums". You are running into this issue because the cookie isn't sent with the request. You will probably have to clear your cookies for this to take effect.
[Image: axolis.png]

Project, Portfolio and Product management for freelancers.
Reply
#3
Not Solved
Will doing this effect the forums?
Reply
#4
Not Solved
No.
Reply
#5
Not Solved
(2015-10-10, 12:20 PM)Nineteh Wrote: Will doing this effect the forums?

No, it won't. The cookie path is there to make sure that in case of multiple MyBB instances under the same domain the cookies don't conflict.
[Image: axolis.png]

Project, Portfolio and Product management for freelancers.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)