Log out of SMF ok, but not in Joomla

Started by DaGoomba, May 15, 2006, 08:09:22 PM

Previous topic - Next topic

DaGoomba

Hi everyone... maybe I can get some help, I have been having problems with Joomla recognizing logins.
 
First off, I had an issue where logins would not show up in Joomla - where the User Menu would be hidden and registered functions would not appear even when logged in. I found this fix for  MOS_SMF.php and it works:

around line 317:

changed:

if ($remember=="yes") {
   $lifetime = time() + 32536000;
   setcookie( "usercookie[username]", $username, $lifetime, "/" );
   setcookie( "usercookie[password]", $passwd, $lifetime, "/" );
   setcookie ("sessioncookie","",-3600, "/" );
}
//mosCache::cleanCache('com_content');

to:

if ($remember=="yes") {
   $lifetime = time() + 32536000;
   setcookie( "usercookie[username]", $username, $lifetime, "/" );
   setcookie( "usercookie[password]", $passwd, $lifetime, "/" );
   $sessionCookieName = md5( 'site'.$GLOBALS['mosConfig_live_site'] );
   setcookie ($sessionCookieName,"",-3600, "/" );
// For Joomla 1.0.8 compatibility
        global $_VERSION;
   if (isset($_VERSION) && $_VERSION->DEV_LEVEL >= '8'){
      $remCookieName    = mosMainFrame::remCookieName_User();
      $remCookieValue = mosMainFrame::remCookieValue_User( $username ) . mosMainFrame::remCookieValue_Pass( $passwd );
      setcookie( $remCookieName, $remCookieValue, $lifetime, '/' );
   }

}
//mosCache::cleanCache('com_content');

AND also changed (~ line 365)


// Empty the cookie! (set it in the past, and for ID_MEMBER = 0)
setLoginCookie(-3600, 0);
setcookie( "usercookie[username]", "", -3600, "/" );
setcookie( "usercookie[password]", "", -3600, "/" );
setcookie ("sessioncookie","",-3600,"/");
mysql_select_db($mosConfig_db);

to:

// Empty the cookie! (set it in the past, and for ID_MEMBER = 0)
setLoginCookie(-3600, 0);
setcookie( "usercookie[username]", "", -3600, "/" );
setcookie( "usercookie[password]", "", -3600, "/" );
$sessionCookieName = md5( 'site'.$GLOBALS['mosConfig_live_site'] );
setcookie ($sessionCookieName,"",-3600, "/" );
if (isset($_VERSION) && $_VERSION->DEV_LEVEL >= '8'){
         $lifetime       = time() - 86400;
         $remCookieName    = mosMainFrame::remCookieName_User();
         setcookie( $remCookieName, ' ', $lifetime, '/' );
}

mysql_select_db($mosConfig_db);


NOW, you can login and both SMF and Joomla see you (where SMF only saw you before) and now when you log out, ou log out of SMF and NOT Joomla. The login dialogue box is there after logging out, but you are still listed in the "Whos Online" module and can still edit/submit news.

How can I get the script to log someone out of both at the same time? I cannot seem to find a fix for this.

Running:
Joomla! 1.0.8 stable
SMF/SMF Registration 3.19
Using OpenSEF 2.0.0-RC5_SP1
local cookies disabled in SMF


Any help would be appreciated... I will submit login information upon request.

http://www.addtoyourspace.com/ [nofollow]

Orstio

There is a known incompatibility with OpenSEF.  Your logout will work if you remove OpenSEF.

DaGoomba

OK, that figures. Would I have to do a complete uninstall of Open SEF or can I just disable it?

Also, is there a workaround to make it work? (Not urgent, I dont really need OpenSEF...)

Thanks for the quick reply.

DaGoomba

Solution doesn't work... first I disabled Open SEF, then uninstalled it. SEF is not enabled in Joomla, and I still do not log out of Joomla after clicking on "Logout".

Any other ideas?

Orstio

Can you paste the code you put into your Joomla template header here?

DaGoomba

I am assuming the code for index.php, here is the entire file.

I dont believe I made any modifications, with the exception of one image file.


--- BEGIN INDEX.PHP ---



<?php
defined( '_VALID_MOS' ) or die( 'Restricted access' );
// needed to seperate the ISO number from the language file constant _ISO
$iso = explode( '=', _ISO );
// xml prolog
echo '<?xml version="1.0" encoding="'. $iso[1] .'"?' .'>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd [nofollow]">
<html xmlns="http://www.w3.org/1999/xhtml [nofollow]">
<head>
<?php mosShowHead(); ?>
<?php
if ( $my->id ) {
   initEditor();
}
$collspan_offset = ( mosCountModules( 'right' ) + mosCountModules( 'user2' ) ) ? 2 : 1;
//script to determine which div setup for layout to use based on module configuration
$user1 = 0;
$user2 = 0;
$colspan = 0;
$right = 0;
// banner combos

//user1 combos
if ( mosCountModules( 'user1' ) + mosCountModules( 'user2' ) == 2) {
   $user1 = 2;
   $user2 = 2;
   $colspan = 3;
} elseif ( mosCountModules( 'user1' ) == 1 ) {
   $user1 = 1;
   $colspan = 1;
} elseif ( mosCountModules( 'user2' ) == 1 ) {
   $user2 = 1;
   $colspan = 1;
}

//right based combos
if ( mosCountModules( 'right' ) and ( empty( $_REQUEST['task'] ) || $_REQUEST['task'] != 'edit' ) ) {
   $right = 1;
}
?>
<meta http-equiv="Content-Type" content="text/html; <?php echo _ISO; ?>" />
<link href="<?php echo $mosConfig_live_site;?>/templates/rhuk_solarflare_ii/css/template_css.css" rel="stylesheet" type="text/css"/>
<?php
global $sc, $context;

if (!defined('SMF')){
  require ("administrator/components/com_smf/config.smf.php");
  require ($smf_path."/SSI.php");
}

$sc = &$context['session_id'];
$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];

mysql_select_db($mosConfig_db);
?>
</head>
<body>

<div align="center">
   <table border="0" cellpadding="0" cellspacing="0" width="808">
      <tr>
         <td class="outline">
              <div id="buttons_outer">
                <div id="buttons_inner">
                  <div id="buttons">
                  <?php mosLoadModules ( 'user3', -1); ?>
                  </div>
               </div>
              </div>
              <div id="search_outer">
                <div id="search_inner">
                <?php mosLoadModules ( 'user4', -1 ); ?>
                </div>
              </div>
              <div class="clr"></div>
              <div id="header_outer">
                 <div id="header">
                 &nbsp;
                 </div>
                 <div id="top_outer">
                  <div id="top_inner">
                  <?php
                    if ( mosCountModules( 'top' ) ) {
                       mosLoadModules ( 'top', -2 );
                    } else {
                       ?>
                       <span class="error">Top Module Empty</span>
                       <?php
                    }
                    ?>
                   </div>
              </div>
              </div>
              <div id="left_outer">
                 <div id="left_inner">
                 <?php mosLoadModules ( 'left', -2 ); ?>
                 </div>
              </div>
              <div id="content_outer">
               <div id="content_inner">
               <?php
                 if ( mosCountModules ('banner') ) {
                    ?>
                    <table border="0" cellpadding="0" cellspacing="0" width="100%" class="content_table">
                  <tr>
                        <td>
                           <div id="banner_inner">
                           <img src="<?php echo $mosConfig_live_site;?>/templates/rhuk_solarflare_ii/images/advertisement.png" alt="advertisement.png, 0 kB" title="advertisement" border="0" height="8" width="468"/><br />
                          <?php mosLoadModules( 'banner', -1 ); ?><br />
                           </div>
                           <div id="poweredby_inner">
                           <a href = "http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=76757769"/ [nofollow] target = "_new"><img src="<?php echo $mosConfig_live_site;?>/templates/rhuk_solarflare_ii/images/addtofriends.gif" border = "0" alt="powered_by.png, 1 kB" title="Make Us Your Friend On MySpace!" border="0" height="68" width="165"/></a/><br />
                           </div>
                        </td>
                     </tr>
                     </table>
                     <?php
                 }
                 ?>
                 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="content_table">
                  <tr valign="top">
                     <td width="99%">
                        <table border="0" cellpadding="0" cellspacing="0" width="100%" class="content_table">

                        <?php
                        if ($colspan > 0) {
                        ?>
                           <tr valign="top">
                              <?php
                             if ( $user1 > 0 ) {
                                ?>
                                <td width="50%">
                                   <div class="user1_inner">
                                   <?php mosLoadModules ( 'user1', -2 ); ?>
                                   </div>
                                </td>
                                <?php
                             }
                             if ( $colspan == 3) {
                               ?>
                                 <td width="2">
                                    <img src="<?php echo $mosConfig_live_site;?>/templates/rhuk_solarflare_ii/images/spacer.png" alt="" title="spacer" border="0" height="10" width="2"/>
                                 </td>
                              <?php
                              }
                             if ( $user2 > 0 ) {
                                ?>
                                <td width="50%">
                                   <div class="user2_inner">
                                   <?php mosLoadModules ( 'user2', -2 ); ?>
                                   </div>
                                </td>
                                <?php
                             }
                              ?>
                           </tr>
                           <tr>
                              <td colspan="<?php echo $colspan; ?>">
                                 <img src="<?php echo $mosConfig_live_site;?>/templates/rhuk_solarflare_ii/images/spacer.png" alt="" title="spacer" border="0" height="2" width="100"/><br />
                              </td>
                           </tr>
                           <?php
                           }
                        ?>
                        <tr>
                           <td colspan="<?php echo $colspan; ?>">
                              <div id="pathway_text">
                              <?php mosPathWay(); ?>
                              </div>
                           </td>
                        </tr>
                        <tr>
                           <td colspan="<?php echo $colspan; ?>" class="body_outer">
                              <?php mosMainBody(); ?>
                           </td>
                        </tr>
                        </table>


                     </td>
                     <?php
                     if ( $right > 0 ) {
                    ?>
                    <td>
                       <div id="right_outer">
                          <div id="right_inner">
                          <?php mosLoadModules ( 'right', -2 ); ?>
                          </div>
                       </div>
                    </td>
                    <?php
                 }
                 ?>

                  </tr>
                  </table>
              </div>
           </div>
        </td>
     </tr>
  </table>
</div>
<?php include_once( $GLOBALS['mosConfig_absolute_path'] . '/includes/footer.php' ); ?>
<?php mosLoadModules( 'debug', -1 );?>
<?php mysql_select_db($db_name); ?>
</body>
</html>

Orstio

OK, good.  That is the only active template, right?  That piece of code needs to go into all active templates, even if they are clones of the main template.

In your SMF admin panel, what is the value of "Use subdomain independent cookies" ?


DaGoomba

Well, there were two templates that came with the install, "madeyourweb" and "rhuk_solitare_ii"... i chose the latter, that is the one that is default.

As for your request:

Default login cookies length - 60
Enable local storage of cookies - disabled
Use subdomain independent cookies - disabled


Thanks in advance for all your help so far, you do amazing work here...  :D

Orstio

Can you enable the subdomain independent cookies, and try again?


Orstio

QuoteNo change.

Actually, there is a change that I noticed from here.  SMF now shows me as logged in, even on your Joomla homepage.  ;)

Are you sure your changes to MOS_SMF.php uploaded to the server correctly?

I am able to login, but the login will not log me into Joomla, which is a good indication that both the login and logout are not working in Joomla.

DaGoomba

Well, that is not the problem. I just created a test account "TestTest", and when you log in, it shows TestTest is active in both Joomla and SMF. When you click on logout, TestTest is no longer active in SMF, but is active in Joomla.

If I log in as Webmaster (Super Admin), and then logout, it says "Hello Guest" on Joomla and still allows me to make changes through edit icons on the Joomla main page along with showing me as still active in the Who's Online module.

I know it is a simple problem somewhere, and I am ready to boot myself in the ass when I find out how simple the fix winds up to be.  :P

Orstio

#12
OK, I think this may be it:

You're missing this in the logout function:

global $_VERSION;


So this:

// Empty the cookie! (set it in the past, and for ID_MEMBER = 0)
setLoginCookie(-3600, 0);
setcookie( "usercookie[username]", "", -3600, "/" );
setcookie( "usercookie[password]", "", -3600, "/" );
$sessionCookieName = md5( 'site'.$GLOBALS['mosConfig_live_site'] );
setcookie ($sessionCookieName,"",-3600, "/" );
if (isset($_VERSION) && $_VERSION->DEV_LEVEL >= '8'){
         $lifetime       = time() - 86400;
         $remCookieName    = mosMainFrame::remCookieName_User();
         setcookie( $remCookieName, ' ', $lifetime, '/' );
}

mysql_select_db($mosConfig_db);


Should be this:

// Empty the cookie! (set it in the past, and for ID_MEMBER = 0)
setLoginCookie(-3600, 0);
setcookie( "usercookie[username]", "", -3600, "/" );
setcookie( "usercookie[password]", "", -3600, "/" );
$sessionCookieName = md5( 'site'.$GLOBALS['mosConfig_live_site'] );
setcookie ($sessionCookieName,"",-3600, "/" );
global $_VERSION;
if (isset($_VERSION) && $_VERSION->DEV_LEVEL >= '8'){
         $lifetime       = time() - 86400;
         $remCookieName    = mosMainFrame::remCookieName_User();
         setcookie( $remCookieName, ' ', $lifetime, '/' );
}

mysql_select_db($mosConfig_db);

DaGoomba

Dude, I think you got it! :D

You are thisclose to being a God among men.

When I logout, the User Menu (registered view only) does disappear, it logs me out of SMF and it logs me out of Joomla (YESSSSSS!)

But, I am still listed in the "Who's Online" module. Does that module now think I am still logged in, or am I listed there as a "recent visitor" until something times out?

(Thank you) ^ infinity.

Orstio

QuoteBut, I am still listed in the "Who's Online" module. Does that module now think I am still logged in, or am I listed there as a "recent visitor" until something times out?

Joomla does not maintain sessions very well, so anything based on that session data is not very accurate.

Try Kindred's mod_smf_online2 from this post:

http://www.simplemachines.org/community/index.php?topic=81152.msg541434#msg541434

DaGoomba


Advertisement: