el archivo de login
Código PHP:
if (isset($_POST['login_submit'])){
$user_login = mysql_query("SELECT * FROM ifdate_users WHERE username='".$_POST['username']."' AND password='".md5($_POST['password'])."'");
if (mysql_num_rows($user_login)==1){
$user_info = mysql_fetch_array($user_login);
if ($user_info['account_status']==0){
$login_error = "<table width=\"100%\" border=\"0\" class=\"error\"><tr><td>".$lang['account_suspended']."</td></tr></table>";
} else {
mysql_query("UPDATE ifdate_users SET last_login='".$today_info."' WHERE username='".$_POST['username']."'");
mysql_query("UPDATE ifdate_users SET active_status='Online' WHERE username='".$_POST['username']."'");
setcookie('iFdate','Active',time()+1800,'/');
setcookie('iFdate_username',$user_info['username'], time()+1800,'/');
setcookie('iFdate_id',$user_info['id'],time()+1800,'/');
echo "<script>document.location.href='wooid_panel.php'</script>";
Arcivo de sesiones
Código PHP:
$user_info = getSqlRow("SELECT * FROM ifdate_users WHERE id='".$_COOKIE['iFdate_id']."'");
$check_info_exists = mysql_query("SELECT * FROM ifdate_users WHERE id='".$_COOKIE['iFdate_id']."' AND username='".$_COOKIE['iFdate_username']."'");
if (mysql_num_rows($check_info_exists)==0){
setcookie ("iFdate","",time()-1800,"/");
setcookie('iFdate_username',"", time()-1800,'/');
setcookie('iFdate_id',"",time()-1800,'/');
}
if ($_COOKIE['iFdate']=="Active"){
mysql_query("UPDATE ifdate_users SET account_timeout='".time()."' WHERE id='".$_COOKIE['iFdate_id']."'");
}
$get_logged_users = mysql_query("SELECT * FROM ifdate_users WHERE active_status='Online'");
while ($got_logged_users = mysql_fetch_array($get_logged_users)){
$logged_users = getSqlField("SELECT account_timeout FROM ifdate_users WHERE id='".$got_logged_users['id']."'",'account_timeout');
if ($logged_users<time()-1800){
mysql_query("UPDATE ifdate_users SET active_status='Offline' WHERE id='".$got_logged_users['id']."'");
}
}
Salu2