I need help with a user session script in PHP with timeout, so if there is no activity on the page it will be redirected to an exit page.
I need help with a user session script in PHP with timeout, so if there is no activity on the page it will be redirected to an exit page.
After the user logs in, you can enter the following code snippet:
<?php
session_start();
session_cache_expire(1800); //o tempo é medido em segundos
?>
In this way, every page that needs the user session, you should check if there is an active user session, like this:
<?
if(!isset($_SESSION)){
//aqui você aplica o redirecionamento
header("Location: ".$enderecoPagina);
}
?>