function clearAuthCookies() { setLoginToken(''); setcookie('AID_USER', '', time() - 1); setcookie('AID_TOKEN', '', time() - 1); setcookie('AID_AUTH', '', time() - 1); }
$_SESSION['user_id'] = $result['user_id']; $_SESSION['batch'] = $result['batch']; $_SESSION['role'] = $result['role_id']; $_SESSION['name'] = $result['first_name'] . $result['last_name']; $_SESSION['email'] = $result['email_primary']; try { $sqllastlogin = '******'; $sthlastlogin = $dbconn->prepare($sqllastlogin); $sthlastlogin->execute(array(':user_id' => $_SESSION['user_id'], ':last_login' => date('m-d-Y'))); } catch (PDOException $e) { echo $e->getMessage(); } //Cookie if ($_POST['remember'] == 'true') { $ipMd5 = md5($_SERVER['REMOTE_ADDR']); $token = setLoginToken('NEW'); setcookie('AID_USER', $result['user_id'], time() + 2592000); setcookie('AID_TOKEN', $token, time() + 2592000); setcookie('AID_AUTH', $ipMd5, time() + 2592000); } else { clearAuthCookies(); } //to check the meta values in user_meta $sqlmeta = "SELECT * FROM user_meta WHERE user_id = :user_id"; $sthmeta = $dbconn->prepare($sqlmeta); $sthmeta->execute(array(':user_id' => $_SESSION['user_id'])); $usermeta = $sthmeta->fetch(PDO::FETCH_ASSOC); $sqlmeta2 = "UPDATE user_meta SET force_welcome=false,force_flash=null,force_pro_update=false,force_tour=false WHERE user_id = :user_id"; $sthmeta2 = $dbconn->prepare($sqlmeta2); $sthmeta2->execute(array(':user_id' => $_SESSION['user_id'])); /*Meta actions*/