refresh session php
this is a session timeout i use.
when the session is initially created:
session_start();
$_SESSION['LAST_ACTIVITY'] = time();
the function that gets called in other pages to update the session timeout when navigating to new pages
function check_timeout($timeout, &$SESSION)
{
if (isset($_SESSION['LAST_ACTIVITY']))
{
if((time() - $_SESSION['LAST_ACTIVITY']) > $timeout)
{
end_session($SESSION);
}
$_SESSION['LAST_ACTIVITY'] = time();
}
else
{
end_session($SESSION);
}
}
i have a separate function (end_session()) to end a session. the & in the parameter allows the session to be updated by the function.
on each page, i call:
session_start();
check_timeout($timeout, $SESSION);