I'm trying to create a script which sets $_SESSION["reverify"]
to TRUE
when 20 minutes have passed without activity on their account (such as page clicks).
Explanation about the
$_SESSION
: When$_SESSION["reverify"]
is set toTRUE
, the user has to reverify him or herself.
I have tried this:
$expire_stamp = date('Y-m-d H:i:s', strtotime("+20 min"));
$now_stamp = date("Y-m-d H:i:s");
if($now_stamp == $expire_stamp) {
$_SESSION["reverify"] == true;
}
But it's not a good script at all, and has so many downsides. Am I overthinking, or just being a noob? I can't get this right.
if (isset($_SESSION['loggedin_time']) && (time() - $_SESSION['loggedin_time'] > 120)) {
$_SESSION["reverify"] = true;
}
if(isset($_SESSION["reverify"]) && $_SESSION["reverify"] = true) {
header("Location: index.php?reverify=true");
}