PHP interesse |
|
Ik denk dat je dit stuk bedoeld:
function check_login() {
if(isset($_SESSION['loginwargame'],$_SESSION['IP']) && $_SESSION['IP'] == $_SERVER['REMOTE_ADDR']) {
if(! isset($_COOKIE['loginwargame'],$_COOKIE['validate'])) {
$validate = md5(rand(0,1000));
setcookie("login",$_SESSION['loginwargame'],time()+60*60*24,"/","");
setcookie("validate",$validate,time()+60*60*24,"/","");
}
else
$validate = $_COOKIE['validate'];
mysql_query("REPLACE INTO `[online]`(`time`,`IP`,`login`,`validate`) values(NOW(),'{$_SERVER['REMOTE_ADDR']}','{$_SESSION['loginwargame']}','$validate')");
return TRUE;
}
else {
if(isset($_COOKIE['login'],$_COOKIE['validate'])) {
$login = $_COOKIE['login'];
$validate = $_COOKIE['validate'];
$query = mysql_query("SELECT * FROM `[online]` WHERE `login`='$login' AND `validate`='$validate' AND `IP`='{$_SERVER['REMOTE_ADDR']}' AND UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`time`) < 60*60*24");
if($user = mysql_fetch_object($query)) {
mysql_query("UPDATE `[online]` SET `time`=NOW() WHERE `login`='$login' AND `validate`='$validate' AND `IP`='{$_SERVER['REMOTE_ADDR']}' AND UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`time`) < 60*60*24");
setcookie("login",$user->login,time()+60*60*24,"/","");
setcookie("validate",$validate,time()+60*60*24,"/","");
$_SESSION['loginwargame'] = $user->login;
$_SESSION['IP'] = $_SERVER['REMOTE_ADDR'];
return TRUE;
}
else {
unset($_SESSION['loginwargame']);
unset($_SESSION['IP']);
setcookie("login",'',time()-100,"/","");
setcookie("validate",'',time()-100,"/","");
return FALSE;
}
}
else {
unset($_SESSION['loginwargame']);
unset($_SESSION['IP']);
setcookie("login",'',time()-100,"/","");
setcookie("validate",'',time()-100,"/","");
return FALSE;
}
}
}
function check_login() { if(isset($_SESSION['loginwargame'],$_SESSION['IP']) && $_SESSION['IP'] == $_SERVER['REMOTE_ADDR']) { if(! isset($_COOKIE['loginwargame'],$_COOKIE['validate'])) { setcookie("login",$_SESSION['loginwargame'],time()+60*60*24,"/",""); } else $validate = $_COOKIE['validate']; mysql_query("REPLACE INTO `[online]`(`time`,`IP`,`login`,`validate`) values(NOW(),'{$_SERVER['REMOTE_ADDR']}','{$_SESSION['loginwargame']}','$validate')"); return TRUE; } else { if(isset($_COOKIE['login'],$_COOKIE['validate'])) { $login = $_COOKIE['login']; $validate = $_COOKIE['validate']; $query = mysql_query("SELECT * FROM `[online]` WHERE `login`='$login' AND `validate`='$validate' AND `IP`='{$_SERVER['REMOTE_ADDR']}' AND UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`time`) < 60*60*24"); mysql_query("UPDATE `[online]` SET `time`=NOW() WHERE `login`='$login' AND `validate`='$validate' AND `IP`='{$_SERVER['REMOTE_ADDR']}' AND UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`time`) < 60*60*24"); $_SESSION['loginwargame'] = $user->login; $_SESSION['IP'] = $_SERVER['REMOTE_ADDR']; return TRUE; } else { unset($_SESSION['loginwargame']); return FALSE; } } else { unset($_SESSION['loginwargame']); return FALSE; } } }
Maar op al mijn overige pagina's werkt het allemaal goed met het session id. Ik probeer nu alleen een script uit een andere source van me in deze nieuwe te zetten maar het session Id krijg ik niet goed. |