Firefox PHP

user_session_restore mod problem

Posted by alandc 
user_session_restore mod problem
June 16, 2013 06:42PM
I've created a user_session_restore mod, using the various approaches discussed on the list. I create a user in the Phorum db to match the userid in my main site.

In main site user validation code:

if( !isset( $_SESSION['phorum_user_id'] ) )
{
$GLOBALS["PHORUM"]["user"]["user_id"] = $userindex;
$_SESSION['phorum_user_id'] = $userindex;
}

and the mod looks like...

/* phorum module info
hook: user_session_restore|mod_ext_user_session_restore
title: External user authentication
desc: This mod enables external user authentication.
*/

function mod_ext_user_session_restore($sessions)
{

if (defined('PHORUM_ADMIN') || defined('PHORUM5_CONVERSION'))
return $session;

if( $sessions[PHORUM_SESSION_SHORT_TERM] || $sessions[PHORUM_SESSION_LONG_TERM] )
return $sessions;

if (!session_id()) session_start();

if( empty($_SESSION['phorum_user_id']) )
{
$phorum_user_id = FALSE;
}
else
{
$phorum_user_id = $_SESSION['phorum_user_id'];
// ---- code gets to here and has the correct userid
// ---- that matches a user in the Phorum database
}
$sessions[PHORUM_SESSION_LONG_TERM] = $phorum_user_id;
$sessions[PHORUM_SESSION_SHORT_TERM] = $phorum_user_id;
if ($phorum_user_id)
{
$user_data = phorum_api_user_get($phorum_user_id);
if ($user_data && ($user_data['admin'] > 0))
{
$session[PHORUM_SESSION_ADMIN] = $phorum_user_id;
}
else
{
$session[PHORUM_SESSION_ADMIN] = FALSE;
}
}
return $sessions;
}

Phorum seems to run the mod and detects the userid however does not appear to actually log the user in. The user still gets a "Registration is required" message.

Any help would be welcome !!

Alan
Re: user_session_restore mod problem
June 16, 2013 07:33PM
Ok fixed the problem

Alan
Re: user_session_restore mod problem
June 17, 2013 07:39AM
It would be nice for others to tell what the solution was in the end ;-)


Thomas Seifert
Sorry, only registered users may post in this forum.

Click here to login