if isset _COOKIE login isset _COOKIE pass login check _COOKIE login pa

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
if(isset($_COOKIE['login']) && isset($_COOKIE['pass'])){
$login = check($_COOKIE['login']);
$password = check($_COOKIE['pass']);
$pass = md5(md5($password));
if(empty($login) or empty($pass)){
setcookie('login', '', time()-cookie_time, '/');
setcookie('pass', '', time()-cookie_time, '/');
}
$user = $db->prepare('SELECT * FROM `users` WHERE `login` = ? AND `pass` = ? LIMIT 1');
$user->execute(array($login,$pass));
$userid = $user->fetch();
if(isset($userid['id'])){
if($userid['login']!=$login or $userid['pass']!=$pass){
setcookie('login', '', time()-cookie_time, '/');
setcookie('pass', '', time()-cookie_time, '/');
}
}
}