How long do you want your session for? The most simple way to do it, is to set a standard session length (60 minutes).
How will you determine what keeps the session active? Will it be following links or actually submitting information and stuff? Simplest way is to update whenever they click a link.
Knowing those two questions you can do something very similar to the following:
<?php
$sess_length = 60*60; // 60 minutes * 60 seconds (3600 seconds)
function createSess($other_info=array()) {
$_SESSION['touched'] = time();
if(!empty($other_info)) {
array_push($_SESSION, $other_info);
}
}
function checkSess() {
/* Check the session. If it's still "active", return true. */
global $sess_length;
if($_SESSION['touched'] > ($time-$sess_length))
return true;
return false;
}
function touchSess() {
$_SESSION['touched'] = time();
}
That would be like an externally linked file (session.php) and you would include that on every page. With each update for your user, you'd use touchSess() to update the session and keep it active. you'd use checkSess() to check the session. And of course you can create your own session initialization functions, I just added one as an example.