Implement this idea:
$expire_time = 3*60*60; //expire time
if( $_SESSION['last_activity'] < time()-$expire_time ) {
echo 'session expired';
die();
}
else {
$_SESSION['last_activity'] = time(); // you have to add this line when logged in also;
echo 'you are uptodate';
}