I want to check how much time has elapsed since the session started and compare with my database column value in INT to see if it's expired and logout the user. in the place of inactive= 10; in my code below i want to pass the db column value either in INT
<?php require_once('Connections/noundb.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
$inactive = 10; // Set timeout period in seconds
if (isset($_SESSION['timeout'])) {
$session_life = time() - $_SESSION['timeout'];
if ($session_life > $inactive) {
session_destroy();
header("Location: l.php");
}
}
$_SESSION['timeout'] = time();
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "l.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>