Reputation: 1291
I'm using a phpBB (2.0.22) in a website, located at myWebSite.com/forum
I am creating some other pages in myWebSite.com/otherForders
What I want, is to check whether a person in logged into myWebSite.com/forum when they are in myWebSite.com/otherForders
Wondering if that's possible.
I've tried session_start(); print_r($_SESSION);
in myWebSite.com/otherForders/index.php and all I get is Array ( )
(an empty array).
Anyone with a solution? Thanks.
Upvotes: 1
Views: 499
Reputation: 1271
You should integrate your board with your code
Here is sample ::
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
Then use
$userdata['username'], $userdata['user_id'] & etc. $userdata has array with values from users_table for your board for logged in user.
Upvotes: 1
Reputation: 86416
The session variable will not accessible in this way. The session cookie of your phpbb is stored at myWebSite.com/forum
and when you visit pages out of forum
directory ie (otherForders)
the session of myWebSite.com/forum
will not available there and a new session will be stared which is obviously a blank array until you assign some values and session cookie for this session is stored at myWebSite.com/otherForders
.
You have to tell php to save session on root domain which is myWebSite.com
so that session will be available in all other directories.
You could do this with ini_set
.
You have to put ini_set
before the session_start()
is called. I don't know about phpbb
if they give any admin interface to change the session cookie domain value. You should check if phpbb provides this.
ini_set('session.cookie_domain','.myWebSite.com');
you could also try
session_set_cookie_params(0, '/', '.myWebSite.com');
session_start();
Upvotes: 1