0
I am having problems, if the user is inactive for more than 24 minutes, the page remains the same.
If I’m on my page and the session is expired due to inactivity (it’s past 24 minutes), I can still interact on the page, but if I want to send the data (I send this data via ajax
) who were already half-populated in the HTML
, the page asks to do log in
again and all this data is lost.
Is there any way to unseal after the session has expired if the user has not interacted with the form? or some other approach I can make?
public function run(){
Session::init();
$uname = $_POST['form-username'];
$upass = $_POST['form-password'];
$database = $this->db;
$query = "
SELECT * FROM tabela
WHERE BINARY user_name=:user_name AND BINARY user_pass=:user_pass LIMIT 1";
$stmt = $database->prepare($query);
$stmt->execute(
array(
':user_pass'=>$upass,
':user_name'=>$uname
)
);
$resultado = $stmt->fetch();
$contador = $stmt->rowCount() ;
Session::set("loggedIn",false);
if($contador > 0){
Session::set("loggedIn",true);
Session::set("id",$resultado['id']);
header("location: ../outrapagina");
} else {
Session::set("mensagemErro","Login ou Senha Errada");
header("location: ../login");
}
}
How are you doing to see if it’s past 24 minutes? Post your code so you can find the help you need.
– Randrade
I actually did not make any arrangements to check whether it passed the 24 minutes, rs.
– denalioasis
Are you at least authenticating? How are you doing to authenticate?
– Randrade
Here you find an answer to expire in 30 minutes, I think it will help you
– Randrade
Otherwise, your question is too wide like this. I advise [Edit] to improve your chances of getting the answer you are looking for
– Randrade
I did an update
– denalioasis
You can send ajax requests constantly to arrive if it is authenticated, or keep an open connection as a server, in which it constantly checks whether or not there is an active session, and when there is not, warns the client.
– mau humor
But I believe that this was going to consume a lot of resource. Maybe you should check this out when the user is going to interact with the page, or form. Like, if it starts to fill a field, you check and if necessary, drop.
– mau humor
You can also send a "Keep Alive" to prevent the session from expiring while the page is active in the browser. This can be every 20 min.
– mau humor