News:

Join the Facebook Fan Page.

Main Menu

Cookies -- AARGH!

Started by Orstio, October 10, 2004, 07:34:12 PM

Previous topic - Next topic

Orstio

I'm working on the integrated login of SMF and Mambo.

All cookies are set, but, for some reason, Mambo does not show the user as logged in.

What am I missing?

Here's the code that sets the cookie:

function MOS_Login2($username=NULL,$passwd=NULL)
{
global $acl;

        $usercookie = mosGetParam( $_COOKIE, 'usercookie', '' );
$sessioncookie = mosGetParam( $_COOKIE, 'sessioncookie', '' );
$remember = "yes";

if (!$username || !$passwd) {
echo "<script> alert(\""._LOGIN_INCOMPLETE."\"); window.history.go(-1); </script>\n";
exit();
} else {
$request = db_query( "SELECT id, gid, block, usertype FROM mos_users WHERE username='$username' AND password='$passwd'", __FILE__, __LINE__);
$row = mysql_fetch_array($request);
// fudge the group stuff
$grp = $acl->getAroGroup( $row->id );
$row->gid = 1;


$row->usertype = $grp->name;

$session =& $this->_session;
$session->guest = 0;
$session->username = $username;
$session->userid = intval( $row->id );
$session->usertype = $row->usertype;
$session->gid = intval( $row->gid );


$currentDate = date("Y-m-d\TH:i:s");
$query = "UPDATE mos_users SET lastvisitDate='$currentDate' where id='$session->userid'";
$sql = mysql_query($query);

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

}
redirectexit();
}

[Unknown]

Are local cookies enabled?

Have you tried print_r'ing $_COOKIE?

-[Unknown]

Orstio

Yes, I even wrote a little script to check to see if the cookie returns any values.  It seems fine, but for some reason, Mambo is not seeing the cookie, unless it is set by Mambo's own login function.

I'll get it sooner or later, I just thought I might get there faster with some help.

[Unknown]

I remember that Mambo used some session code to make sure they had a logged in session... are you checking that?

-[Unknown]

Orstio

Got it, thanks.   :D

I had to expire the Mambo session cookie on login.

Advertisement: