Forum Moderators: coopster & phranque

Message Too Old, No Replies

Login Issue

can't identify what's causing users to login twice

         

milocold

11:21 pm on Mar 14, 2005 (gmt 0)

10+ Year Member



Greetings all,

Ok, I'm nothing near a Perl rookie. That being said here's the issue...

I am currently troubleshooting someone else's script and I have no clue what I'm doing. The problem is that once users login with a correct user/pass, they get taken to the client's main menu. From there they have 2 links that take them to either destination A or destination B. Though when a user gets to the client menu and click on either Dest. A or B they are taken to the main login screen again and are forced to...well, login again.

I know without putting code samples the problem is too vague for immediate diagnosis, I'm more interested in if anyone has experienced a problem similar to this and if it was something well known within CGI community.

My starting point will be to install an apache server w/ mod_perl, but I haven't started researching how to accomplish that task. So that escapade is for later tonight. After that I'm gonna disect the code until more info appears.

Thanks in Advance,
M. Cold

milocold

12:35 am on Mar 15, 2005 (gmt 0)

10+ Year Member



Interesting, upon further functionality testing I discovered that the login and logout functions do work properly, but just take their sweet ol' time. Here's the code for the login/logout:

¦-> code start
sub login {
my ($user,$pass) = @_;
my ($q,$res,$status,$cpass);

return(0, 'Invalid username.') unless defined($user);
return(0, '#*$!Invalid password.') unless defined($pass);

# fetch account id if valid user
$q = qq{SELECT id,status,password FROM accounts };
$q .= qq{WHERE username =?};
$res = $QUERY->select($q, [$user]);

unless ( $res->num_rows() ) {
return(0, 'Username not found.');
}

$UID = $res->value(1,1);
$status = $res->value(1,2);
$cpass = $res->value(1,3);

unless (crypt($pass, $cpass) eq $cpass) {
return(0, 'Invalid password.');
}

unless (lc($status) eq 'active') {
return(0, "User '$user' is inactive.");
}

# update session table
$QUERY->update( table => 'sessions',
data => {account_id=>$UID},
where => ['session_id =?', $SID],

);

return(1, undef);
}

#--------------------------------------------
sub logout {
my $session_id;
my $cname = $CONFIG{cookie_key} ¦¦ '_'.$APPNAME.'_';
my $sid = $COOKIES{$cname};

return unless defined($sid);

$QUERY->delete( table => 'sessions',
where => ['session_id =?', $sid],

);
kill_cookie();
}

¦-> code End

Just curious could the session update/delete be causing the slow response time?

Thanks in Advance

Moby_Dim

6:34 am on Mar 15, 2005 (gmt 0)

10+ Year Member



Nothing is impossible in this world, phone-type diagnosis too ;) Code snippets may not be the right source. First check how session tracking implements there. Get or post? (I suspect first, check the url). Or are there hidden fields in the form to keep data? Cookies may work alone or to be a part of more complex session tracking.

adni18

1:36 pm on Mar 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you trying to log into another system, too? Like, if you are logging into a member system + phpBB at the same time? Or is it a duplicate funtion?

milocold

7:16 pm on Mar 15, 2005 (gmt 0)

10+ Year Member



>> Nothing is impossible in this world, phone-type diagnosis too ;)

Hmmm...don't get it?

>> First check how session tracking implements there. Get or post?

Your are correct, it's GET. No hidden forms exist either.

>> Are you trying to log into another system, too?

Nope, and I'm not sure what a duplicate funtion is...could you explain?

Thank you guys very much

_Milo

Moby_Dim

8:06 pm on Mar 15, 2005 (gmt 0)

10+ Year Member



Milo, who could tell you for sure where the problem's roots while having just a small piece of code? I can't :( To understand this one may need the clear understanding of the whole system, it's logic, algo. Obviously, this's not a simple syntax error. Or (if you are lucky) somebody who knows this script/program already would see this here. Or the Real GURU (who can see things invisible for others:)

milocold

8:56 pm on Mar 15, 2005 (gmt 0)

10+ Year Member



Suckie...*sigh* Perhaps it's time for Perl for Dummies. Thanks anyway!

=o)