6
What happens when Session time expires ? (This time is usually 24 minutes by default).
Example:
When logging in we set the credentials of a particular user on $_SESSION
, with the data resulting from a SELECT
(a query) made in the database, as below:
$_SESSION["id_usuario"] = $retorno_select["id"];
$_SESSION["nome"] = $retorno_select["nome"];
$_SESSION["email"] = $retorno_select["email"];
$_SESSION['usuario'] = $retorno_select['usuario'];
$_SESSION["departamento-usuario"] = $retorno_select["departamento"];
$_SESSION['permissao'] = $retorno_select['permissao_acesso'];
So on every page I want to check the user’s access permission, or utilize some user data (like even a simple "Bom dia, $_SESSION['nome']"
), i give a session_start()
to start this Session.
My question is the following: when finishing this 24 minutes (SESSION’s default duration time) what happens to this data that was set ? Like this one below for example:
$_SESSION["nome"] = $retorno_select["nome"];
That one $_SESSION["nome"]
, and all the others that were created are destroyed ? The values that were passed to them are erased and they remain active?
What happens to SESSION if it expires and I give a F5 (refresh) on the page and that page has a session_start()
?
What happens if SESSION has a life time of 24 minutes and when it has 15 minutes I give a F5 (refresh) on the page ? Your counter will continue counting from 15 minutes or this counter will reset and start again ?
What happens when we make an AJAX request in a file .php
that has a session_start() in it ? The life time of SESSION is reset ?
How do we use PHP code to increase the time of a created session ? For example, we enter a page, the session is "running" (already with a lifespan of 15 minutes) and the session has that lifespan pattern of 24 minutes. So we want to increase this lifespan from 24 minutes to 1 hour. How would we do in the page archive ? It could also be set this "default" time increase at the time we log in and fill it with user data.
After SESSION has expired (past 24 minutes), what happens, for example, if I enter a file, give a session_start()
and execute one of the commands below?
session_start();
if(isset($_SESSION["nome"])){
return true;
}
else{
return false;
}
Or:
session_start();
if(empty($_SESSION["nome"])){
return true;
}
else{
return false;
}
Or:
session_start();
if($_SESSION["nome"]){
return true;
}
else{
return false;
}
Thanks for the editing, @hkotsubo. I wrap myself around posting PHP codes here.
– Gato de Schrödinger
Ajax or normal back-end request is all HTTP, it doesn’t fully understand the difference of what happens on your front, so I explained in the reply about LOCK, indicated the link https://answall.com/a/57827/3635 and talked about it, how it will release only as another conclusion, that is, being ajax or normal, it will be HTTP and ajax will only load when the main page completes the use of the session.
– Guilherme Nascimento