I've built web apps before that utilize phpBB session, and user data. The common move is to use code like this:
define('IN_PHPBB', true); //replace $phpbb_root_path with path to your forum $phpbb_root_path = '../forum/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup();
However, by including
common.php, I bring along a crap-load of other methods that run into other methods I've got setup.
In my example, I'm running the application using CodeIgniter, which already has a "redirect" method. This question should apply to anyone who has pre-built methods that may run into the phpBB methods.
Basically, all I need to do is:
- Make sure the user is logged in
$user->data[username] == Anonymous
- Utilize data from '$user->data' such as the user's ID, screenname, etc.
Could I grab the
$user->data array, and somehow save it to my own session? Does anyone have any ideas on this? Thanks in advance!
You have run into the primary reason i hate frame works. You never know just what is being included. Especially when the code is not object orientated. (much better if your function belong to objects, rather than floating free in a global space.)
Assuming your code has a defined session handler already in place, there is nothing stopping you from using the regular session commands.
eg: $_SESSION['user_data_array'] = $user->data ;
then later on using teh session data
$data = $_SESSION['user_data_array'];
When a session handler is written, it replaces the current session handler. (I assume that has been done so that the session is stored in the database, rather than on the server.)
If it has not be replaced, then you can still use PHP's the default session handler.. Always bear in mind that the session details are saved to a folder on the current webserver. So if your application is run across multiple servers, the session data will be unavailable if the user is being served by a different server on a subsequent visit. (hence the need for writing session handlers to preserve the session data between multiple servers.)