Firefox PHP

user_session_restore doesn't seem to be working

Posted by shwonkbc 
user_session_restore doesn't seem to be working
September 01, 2009 11:04PM
Hi Phorum!

I'm having a little trouble with one of your hooks, user_session_restore.

Basically, I already have a log in system on my site, and would like for my users not to have to log in twice to use the board. Reading through the hooks, I found out the way to do this is through user_session_restore. Here's my code:

function phorum_mod_booze_user_session_restore($sessions) {

$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$ident = $auth->getIdentity();
if($ident->role == 'member')
{
$user_id = (int)$ident->user_id;
}
}

if(!$user_id)
{
$user_id = false;
}

$sessions[PHORUM_SESSION_SHORT_TERM] = $user_id;
$sessions[PHORUM_SESSION_LONG_TERM] = $user_id;

return $sessions;
}

Basically it checks my auth, and if they're logged in, it sets $user_id to the user_id. I have checked with var_dump, and it is successfully doing this. (SHORT_TERM = 2, LONG_TERM = 2, ADMIN = null). I know I have added the module correctly, because editing code inside of the module has repercussions.

I have tried
$user = phorum_api_user_get($user_id);
if (empty($user)) {
trigger_error("User with user_id $user_id does not yet exist in Phorum!", E_USER_ERROR);,
and it does get the correct user when I var_dump that too, so i know I'm doing everything right.

However, it's not working. Even when I know i've made $sessions correctly, it will not allow my users to post. When I try to let them it says "Sorry, only registered users may post in this forum. " Do you know what could be causing this? It's very frustrating. Thanks!
Re: user_session_restore doesn't seem to be working
September 02, 2009 12:50AM
I am afraid you will have to trace some of the code in include/api/user.php regarding this hook. Based on what I see here, the hook should work and the integration should be functional.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: user_session_restore doesn't seem to be working
September 02, 2009 10:49AM
Sure, i'd be happy to. Do you have any suggestions of where to look?
Re: user_session_restore doesn't seem to be working
September 02, 2009 11:03AM
Best place to start: function phorum_api_user_session_restore() in include/api/user.php

But before you do so, one very obvious option popped up in my head. Please check if you have used active = 1 for the users that you created in the Phorum users database table.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: user_session_restore doesn't seem to be working
September 02, 2009 11:14AM
That was it!!! Thank you so much! You make me glad I picked you guys.
Re: user_session_restore doesn't seem to be working
September 02, 2009 11:35AM
You had already been so thorough, that it made me forget the obvious ;-) Have fun with it!


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login