1
I’m creating a system to check if the user entered the site an hour ago or earlier. There’s a column in the database that speaks last time you logged on Last_login(int4) the date has to be in this format ymdHm(1703221703).
My problem is that I don’t know how I can verify this, whether it logged in 1 hour ago or earlier, or whether it is logged in.
My code I’ve made so far:
public function check_time(){
$date = new \DateTime();
//echo $date->format('ymdHm');
$conexao = new Config;
try{
$conect = $conexao->getConn();
$prepare = $conect->prepare("SELECT * FROM accounts WHERE login = ?");
$prepare->bindvalue(1, $_SESSION['username']);
$prepare->execute();
$dados = $prepare->fetch(PDO::FETCH_ASSOC);
if ($prepare->rowCount() >= 1){
//return $dados['last_login'];
if($dados['last_login'] ==
}
}catch(PDOException $e){
echo "Erro: ".$e->getMessage();
}
}
Welcome to the Guilherme site. Do you want to check if the user logged in more than 1 hour ago? What if he did but navigated between several pages? Do you want this to be considered as well? As you are new, enjoy and take a look at tour.
– jlHertel
Don’t just check if he logged on an hour ago or earlier.
– Guilherme