SMF/Xoops Bridge: Cookie and Session Errors When Attempting to Login

Started by zandraya, December 10, 2007, 02:48:54 PM

Previous topic - Next topic

zandraya

I'm a first time user of SMF and I want to say how impressed I am with the community, the support system and the well thought out bridges.  I came here after spending a good chunk of time researching forums that I could use with Xoops instead of Newbb.  I'm happy with SMF except that I cannot seem to get the bridge to fully work.  I've been working on this for the past 4 days and although I have been developing websites for over 10 years, I am a complete newbie when it comes to Linux and PHP.  I did enlist the help of my webhost who also spent a considerable amount of time looking into it, but unfortunately neither of us have been able to resolve the issue.

Things have grown worse today and I'm not even able to access my admin area.   :'(  Even when I'm logged into the forums and click on the admin button I get: 

"Session verification failed. Please try logging out and back in again, and then try again." 

I've logged out and back in, deleted my cookies and tried again...repaired settings with repair_settings.php and I simply cannot administer my SMF application now.

The error URL for this is:

hxxp:www.guildverity.com/smf/index.php?action=admin [nonactive]

The main problem I've been having for the past 4 days is:

If you go to hxxp:www.guildverity.com [nonactive] and login using the SMF login you get the following error on the SMF page:

"You were unable to login. Please check your cookie settings."

The error URL for this is:  hxxp:www.guildverity.com/xoops/htdocs/modules/smf/index.php?action=login2;sa=check;member=2. [nonactive]

NOTE:  Previously I was getting this error:  "Fatal error: session_start(): Failed to initialize storage module: user (path: /tmp) in /home/guildverity/smf/Sources/Load.php on line 1947."  If I turned on database driven sessions I would no longer get the fatal error, but instead: "You were unable to login.  Please check your cookie settings."  Unfortunately I'm not sure what I changed to flip the errors.

My SMF settings are currently (but they've been every combination at some point):

Enable local storage of cookies: OFF
Use subdomain independent cookies: ON
Enable compressed output: ON
Use database driven sessions: OFF
Session expiration:  3000

My Xoops settings are:

Use custom session:  YES
Session expiration:  3000

Additional information:

Xoops Version:  2.0.16
SMF version:  1.1.4
MySQL version: 4.1.20

My phpinfo:

hxxp:www.guildverity.com/phpinfo.php [nonactive]

My webhost's phpinfo:

hxxp:69.80.208.155/phpinfo.php [nonactive]

I have read everything I can find on this error in these forums and elsewhere and I've tried all the suggestions, but nothing seems to work.  I have never posted on a support forum before because I am generally able to resolve things on my own, but I've met my match here.   :-[

I would very greatly appreciate any help.  Thank you in advance!   :)

zandraya

Update:  I'm able to login to the admin section again.  I still need help with the cookies if someone would be kind enough to offer a suggestion.  Thanks.  :)

Orstio

Try this:

In your modules/smf folder is a file named index.php.  Open it in Notepad, and find this:

define('SMF_INTEGRATION_SETTINGS', serialize(array(
'integrate_change_email' => 'integrate_change_email',
'integrate_reset_pass' => 'integrate_reset_pass',
'integrate_exit' => 'xoops_smf_exit',
'integrate_logout' => 'integrate_logout',
'integrate_outgoing_email' => 'integrate_outgoing_email',
'integrate_login' => 'integrate_login',
'integrate_validate_login' => 'integrate_validate_login',
'integrate_redirect' => 'integrate_redirect',
'integrate_delete_member' => 'integrate_delete_member',
'integrate_register' => 'integrate_register',
'integrate_pre_load' => 'integrate_pre_load',
)));


Change it to this:

define('SMF_INTEGRATION_SETTINGS', serialize(array(
'integrate_change_email' => 'integrate_change_email',
'integrate_reset_pass' => 'integrate_reset_pass',
'integrate_exit' => 'xoops_smf_exit',
'integrate_logout' => 'integrate_logout',
'integrate_outgoing_email' => 'integrate_outgoing_email',
'integrate_login' => 'integrate_login',
'integrate_validate_login' => 'integrate_validate_login',
'integrate_redirect' => 'integrate_redirect',
'integrate_delete_member' => 'integrate_delete_member',
'integrate_register' => 'integrate_register',
'integrate_pre_load' => 'integrate_pre_load',
'integrate_verify_user' => 'integrate_verify_user',
)));


Then, at the end of the file, right before the "?>", add this:

function integrate_verify_user ()
{
global $xoopsUser, $db_prefix;

if (is_object($xoopsUser) && $xoopsUser->getVar('uname')){
$query = mysql_query("
SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE memberName = '" . $xoopsUser->getVar('uname') . "'");
list($ID_MEMBER) = mysql_fetch_row($query);
}

return $ID_MEMBER;
}


Now, use your regular Xoops login block instead of the bridge login block.

zandraya

Amazing!!  You have made me one happy girl, Orstio!  It appears that I can now use the Xoops login to login to both Xoops and SMF.   :D  The only problem, and maybe it's something I did wrong, but when I click on the "Logout" button on SMF I get this error:

"Fatal error: Call to a member function getVar() on a non-object in /home/guildverity/xoops/htdocs/modules/smf/index.php on line 476"

Line 476 is this for me:

if ($xoopsUser->getVar('uname')){

Any suggestions here?  This certainly isn't urgent, but I would like to be able to fix it sometime down the road.

Thanks again, I'm thrilled with the results so far.   :)

Orstio

Change it to this:

if (is_object($xoopsUser) && $xoopsUser->getVar('uname')){

zandraya

That worked!  I removed the SMF login areas on the forums temporarily until I have time to hook them up to Xoops.  I'm just extremely happy that the login is working now.   :)

Thanks again for the help!!


Kiwi_Chris

Thank you for the help, I used this same script to help unify my login system on xoops/smf which is working.

The issue have now is non logged in users can no longer see the Forum without logging in.

It should be possible to view forums when not logged in.

I have checked permissions on SMF and Xoops and both allow for Guests to view.
but all i get is a blank page unless logged in.

Thank you in advanced.

Kiwi Chris.

Kiwi_Chris

Quote from: Orstio on December 10, 2007, 07:58:43 PM
Try this:

In your modules/smf folder is a file named index.php.  Open it in Notepad, and find this:

define('SMF_INTEGRATION_SETTINGS', serialize(array(
'integrate_change_email' => 'integrate_change_email',
'integrate_reset_pass' => 'integrate_reset_pass',
'integrate_exit' => 'xoops_smf_exit',
'integrate_logout' => 'integrate_logout',
'integrate_outgoing_email' => 'integrate_outgoing_email',
'integrate_login' => 'integrate_login',
'integrate_validate_login' => 'integrate_validate_login',
'integrate_redirect' => 'integrate_redirect',
'integrate_delete_member' => 'integrate_delete_member',
'integrate_register' => 'integrate_register',
'integrate_pre_load' => 'integrate_pre_load',
)));


Change it to this:

define('SMF_INTEGRATION_SETTINGS', serialize(array(
'integrate_change_email' => 'integrate_change_email',
'integrate_reset_pass' => 'integrate_reset_pass',
'integrate_exit' => 'xoops_smf_exit',
'integrate_logout' => 'integrate_logout',
'integrate_outgoing_email' => 'integrate_outgoing_email',
'integrate_login' => 'integrate_login',
'integrate_validate_login' => 'integrate_validate_login',
'integrate_redirect' => 'integrate_redirect',
'integrate_delete_member' => 'integrate_delete_member',
'integrate_register' => 'integrate_register',
'integrate_pre_load' => 'integrate_pre_load',
'integrate_verify_user' => 'integrate_verify_user',
)));


Then, at the end of the file, right before the "?>", add this:

function integrate_verify_user ()
{
global $xoopsUser, $db_prefix;

if ($xoopsUser->getVar('uname')){
$query = mysql_query("
SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE memberName = '" . $xoopsUser->getVar('uname') . "'");
list($ID_MEMBER) = mysql_fetch_row($query);
}

return $ID_MEMBER;
}


Now, use your regular Xoops login block instead of the bridge login block.






This worked for me, and all is looking good only issue I am now having is with
Guests viewing the Forum it will show a blank page.

any user that is logged in can see the forum just fine.


Permissions have been done and redone both in forum and xoops permissions.
Guests can see the menu link to forum, which they can not do if they don't have permission.

Please, anyone have any ideas of what may cause this?

Kiwi_Chris

Ok I have worked a work around.

It appears that I could access the SMF just fine it was trying to access the wraped part of SMF,  i.e. if i go http://mysite.com/module/smf [nofollow] as a guest FAILS
if I go direct to SMF i.e. http://mysite.com/smf [nofollow] i was able to view SMF,
I did have to change the server settings for forum URL, because before that Guest could access forum but and clicks would send them back to http://mysite.com/module/smf [nofollow] which would fail again.

So now my site uses different menu links for Guest and Registered users.
From a users point of view theirs only one Link to click on, Registered sees module link and guests see direct link.

I would still like to find a more permanent solution.

Orstio

You need to change this line:

if ($xoopsUser->getVar('uname')){


To this:

if (is_object($xoopsUser) && $xoopsUser->getVar('uname')){

Kiwi_Chris


anakein

I have one errors: Notice: Undefined index: rand_code in file /modules/smf/index.php line 90
and if xoops user dont exist into smf dont insert user into smf.

Migraine

Quote from: Orstio on December 10, 2007, 07:58:43 PM
Try this:

In your modules/smf folder is a file named index.php.  Open it in Notepad, and find this:

define('SMF_INTEGRATION_SETTINGS', serialize(array(
'integrate_change_email' => 'integrate_change_email',
'integrate_reset_pass' => 'integrate_reset_pass',
'integrate_exit' => 'xoops_smf_exit',
'integrate_logout' => 'integrate_logout',
'integrate_outgoing_email' => 'integrate_outgoing_email',
'integrate_login' => 'integrate_login',
'integrate_validate_login' => 'integrate_validate_login',
'integrate_redirect' => 'integrate_redirect',
'integrate_delete_member' => 'integrate_delete_member',
'integrate_register' => 'integrate_register',
'integrate_pre_load' => 'integrate_pre_load',
)));


Change it to this:

define('SMF_INTEGRATION_SETTINGS', serialize(array(
'integrate_change_email' => 'integrate_change_email',
'integrate_reset_pass' => 'integrate_reset_pass',
'integrate_exit' => 'xoops_smf_exit',
'integrate_logout' => 'integrate_logout',
'integrate_outgoing_email' => 'integrate_outgoing_email',
'integrate_login' => 'integrate_login',
'integrate_validate_login' => 'integrate_validate_login',
'integrate_redirect' => 'integrate_redirect',
'integrate_delete_member' => 'integrate_delete_member',
'integrate_register' => 'integrate_register',
'integrate_pre_load' => 'integrate_pre_load',
'integrate_verify_user' => 'integrate_verify_user',
)));


Then, at the end of the file, right before the "?>", add this:

function integrate_verify_user ()
{
global $xoopsUser, $db_prefix;

if (is_object($xoopsUser) && $xoopsUser->getVar('uname')){
$query = mysql_query("
SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE memberName = '" . $xoopsUser->getVar('uname') . "'");
list($ID_MEMBER) = mysql_fetch_row($query);
}

return $ID_MEMBER;
}


Now, use your regular Xoops login block instead of the bridge login block.


The fix above helped between my SMF and Xoops (thank you Orstio!), but three problems are occurring that I do not know how to resolve.

First, if a member logs into Xoops side they can access SMF just fine, but the logout button on SMF does nothing other than refreshes the page.  How can I fix this to log out of the Xoops and SMF if using the logout button in SMF?


Secondly, a member logging into the SMF end (via the bridge aka modules/smf) seems to do nothing other than refreshes the page, but if I link directly to the actual SMF url afterward it shows the account as being logged in.


Finally, I've noticed new accounts made on either Xoops or SMF are not recognized by each other, so I'm uncertain what I need to do to the databases for them to work together.

Any and all suggestions are appreciated.  :)

Running
SMF 1.1.10
Xoops 2.3.0
using SMF Module for Xoops to bridge

~Migraine


Orstio

In Xoops, what do you have set for "Use Custom Session"?

In SMF, what are your settings for:

Database driven sessions?
Subdomain independent cookies?
Local storage of cookies?

Migraine

In Xoops, what do you have set for "Use Custom Session"?   YES

In SMF, what are your settings for:

Database driven sessions?  Checked
Subdomain independent cookies?  Unchecked
Local storage of cookies?  Unchecked

:) Thanks for any insight Orstio!   :)

Orstio


Migraine

Turned on subdomain independent cookies, and still the same problems exist.  ???

Orstio

Can you try turning off custom sessions in Xoops?

I have a Xoops 2.3.x and SMF 2.0 RC1 integration that works with it off.

Advertisement: