i don't understand what's causing the logout to occur so fast since it's not time dependant. i've added (and since removed) a number of debugging lines thinking it was the expiration time on the cookies, but it's not. that's being done right. for some reason it's getting reset.
since the functions that are involved are varoius and mant, i'm showing the one i think is the most likly culprit below, with a link to a page with just the full functions used and the login script below that.
Code: Select all
if($_COOKIE['login']){ # we're logged in
$db=mysql_connect($host, $login2, $pass2) or die("cannot access mysql"); # get the sql connection
$fyd=mysql_select_db('findyourdesire', $db) or die("cannot connect to db"); # select the db
$un=$_COOKIE['un']; $pw=$_COOKIE['pw']; # what we wont change on-the-fly
$fprefs=mysql_query("SELECT gmt_offset, tds, login_duration, msgs FROM users WHERE username='$un' AND password='$pw'", $db); # get the prefs
if(mysql_num_rows($fprefs)>0){ # we can update the cookies
$prefs=mysql_fetch_array($fprefs); $gmto=$prefs['gmt_offset']; $utds=$tds[$prefs['tds']];
$duration=$durr[$prefs['login_duration']]; $accepts=$prefs['msgs'];
$expire=(time()+($duration*60));
setcookie(un, $un, $expire); # set username
setcookie(pw, $pass, $expire); # set password
setcookie(login, TRUE, $expire); # set login
setcookie(gmto, $gmto, $expire); # set the gmt offset
setcookie(utds, $rtds, $expire); # set the time display style
$active=gmdate("Y-m-d H:i:s", time());
$update=mysql_query("UPDATE users SET last_activity='$active' WHERE username='$un'", $db); # try to update users (we don't really care if it fails)
if($accepts){ # person accepts ims
if($accepts>5){ # the user wants them ALL
$fims=mysql_query("SELECT msg_id FROM msgs WHERE to_id='$un' AND viewed='0'", $db);
$amtims=mysql_num_rows($fims);
if($amtims){ # we have ims
for($i=0;$i<$amtims;$i++){ # for each im
$gimid=mysql_fetch_array($fims); $ims=$gimid['msg_id']; # record the msg_id
}
}
}else{ # user wants $accepts amount
$fims=mysql_query("SELECT msg_id FROM msgs WHERE to_id='$un' AND viewed='0' ORDER BY msg_id ASC LIMIT '$accepts'", $db);
$amtims=mysql_num_rows($fims);
if($amtims){ # we have ims
for($i=0;$i<$amtims;$i++){ # for each im
$gimid=mysql_fetch_array($fims); $ims=$gimid['msg_id']; # record the msg_id
}
}
}
}
}else{ cookies('logout'); } # there was an error for some reasonhttp://24.91.157.113/findyourdesire/login.issue