ti mando il codice che c'è già in b.php

<?php


$minutes=5;//Setta logout in minuti

if (isset($_SESSION["time"])) {
$sessionTTL = time() - $_SESSION["time"];
if ($sessionTTL > $minutes*60) {
session_unset();
session_destroy();
header("location:index.php");//redirect user to a login page or any page to which we want to redirect.
}
}else {
session_unset();
session_destroy();
header("location:index.php");//redirect user to a login page or any page to which we want to redirect.
}


$_SESSION["time"] = time();

?>