Forum Session variable problem

Submitted by Anonymous on Fri, 06/01/2012 - 13:14
Written by


I am new to useBB and seem to be having some problems implementing session variables within the forum.

I am trying to create a new session variable when the user logs into the system. Something like:

$_SESSION['user'] = "TEST";

However when i try to access this session in a directory outside of the forum it does not pick it up:

echo "LOGGED IN";

The code above always echo's 'NOT LOGGED IN'

Could anyone give me any pointers on what I'm doing wrong?


Ensure UseBB's cookie path setting is set to "/". You must also only use the variable when common.php has been loaded, and preferrably not use session_start() yourself.


Thanks for your reply.

I have tried what you have mentioned but with no success. I presume setting the cookie path to '/' makes it apply to the whole domain?

Is there anything else you can suggest?


I think you are not reopening the session created by UseBB. Try experimenting with session_set_cookie_params() to get the exact same settings as set by UseBB (domain, path, etc).

Hi again,

Forgive but I'm new to PHP. I tried this code but doesn't seem to work:

session_set_cookie_params( time() + 600, '/', '', false, false);

Still can't pick up sessions defined within UseBB. Is this the right way of using this?

Note "" will probably only work for that exact host, not Therefore you would use "".

I can't really see where exactly you are setting the session variable. If you do this in UseBB I would do this at the end of sources/common.php, and read the variable in your own system. In UseBB itself you then do NOT call session_*() yourself.

If it doesn't work the code or settings might still be wrong.

Thanks very much for your help, I have it working now