1
   

How to share sessions between PhpBB and another application

 
 
Reply Fri 7 Jan, 2005 08:47 pm
Hello,

I am trying to develop a PhpBB application to function as a support forum for registered users. The problem I am having is getting PhpBB to cue the other MySql Table for the session, and specify the other Cookie.

I have set-up another db user with read permission to the other MySql Table. I am guessing that I now need to specify, somewhere in PhpBB, to cue the other table, with the read permission username.

I assume that specifying the other Cookie name in the PhpBB admin panel would make the program seek the other cookie on the users computer. However, I noticed the domain will not match. I am wondering if that would cause conflicts.

Is this possible, and what would be the best way to perform the task?
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 1 • Views: 668 • Replies: 6
No top replies

 
Craven de Kere
 
  1  
Reply Sat 8 Jan, 2005 06:54 pm
What are you talking about when you say "cue the other table"?
0 Replies
 
learningphp
 
  1  
Reply Sat 8 Jan, 2005 08:13 pm
I have two seperate tables
Hello Craven,

I am using two unique tables, well actually three. Each powers a seperate application. If someone should register for PhpBB application, they would not be logged in or registered on the other two.

I am trying to make all the users data and sessions, become stored in table A (MySql).

The PhpBB application is going to be used as a Support Area. I dont want people to need to register for support, or have the ability to abuse the PhpBB application.

I am trying to grasp how this all works. I have read some basic tutorials, but I believe this is much more advanced. I can recognize where each program starts a session and looks for a session ID and cookie, I just cannot configure them to work off the same table.
0 Replies
 
Craven de Kere
 
  1  
Reply Sat 8 Jan, 2005 08:15 pm
I'd not do it that way. I'd use one single user table and authenticate all the applications off of it.
0 Replies
 
learningphp
 
  1  
Reply Sat 8 Jan, 2005 08:27 pm
I think that is what I am attempting to configure. I just cannot figure out how to tell PhpBB, look at this table for this cookie, username etc...

Here is where I was looking at making the change:

PhpBB includs/sessions.php:
Code://
// Adds/updates a new session to the database for the given userid.
// Returns the new session ID on success.
//
function session_begin($user_id, $user_ip, $page_id, $auto_create = 0, $enable_autologin = 0)
{
global $db, $board_config;
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;

$cookiename = $board_config['cookie_name'];
$cookiepath = $board_config['cookie_path'];
$cookiedomain = $board_config['cookie_domain'];
$cookiesecure = $board_config['cookie_secure'];

if ( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename . '_data']) )
{
$session_id = isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : '';
$sessiondata = isset($HTTP_COOKIE_VARS[$cookiename . '_data']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename . '_data'])) : array();
$sessionmethod = SESSION_METHOD_COOKIE;
}
else
{
$sessiondata = array();
$session_id = ( isset($HTTP_GET_VARS['sid']) ) ? $HTTP_GET_VARS['sid'] : '';
$sessionmethod = SESSION_METHOD_GET;
}

//
if (!preg_match('/^[A-Za-z0-9]*$/', $session_id))
{
$session_id = '';
}

$last_visit = 0;
$current_time = time();
$expiry_time = $current_time - $board_config['session_length'];

//
// Try and pull the last time stored in a cookie, if it exists
//
$sql = "SELECT *
FROM " . USERS_TABLE . "
WHERE user_id = $user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Could not obtain lastvisit data from user table', '', __LINE__, __FILE__, $sql);
}

$userdata = $db->sql_fetchrow($result);

if ( $user_id != ANONYMOUS )
{
$auto_login_key = $userdata['user_password'];

if ( $auto_create )
{
if ( isset($sessiondata['autologinid']) && $userdata['user_active'] )
{
// We have to login automagically
if( $sessiondata['autologinid'] == $auto_login_key )
{
// autologinid matches password
$login = 1;
$enable_autologin = 1;
}
else
{
// No match; don't login, set as anonymous user
$login = 0;
$enable_autologin = 0;
$user_id = $userdata['user_id'] = ANONYMOUS;
}
}
else
{
// Autologin is not set. Don't login, set as anonymous user
$login = 0;
$enable_autologin = 0;
$user_id = $userdata['user_id'] = ANONYMOUS;
}
}
else
{
$login = 1;
}
}
else
{
$login = 0;
$enable_autologin = 0;
}


When I modified this, I was getting an error. Should I migrate the PhpBB tables to the same DB on the host to make it work?
0 Replies
 
Craven de Kere
 
  1  
Reply Sat 8 Jan, 2005 08:30 pm
You can see my advice above.

Edit: that's how I would do it. But I don't have time to write the code for you.
0 Replies
 
learningphp
 
  1  
Reply Sat 8 Jan, 2005 08:34 pm
I see
I see, thanks for the advice.
0 Replies
 
 

Related Topics

Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
 
  1. Forums
  2. » How to share sessions between PhpBB and another application
Copyright © 2025 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 01/18/2025 at 01:54:51