The most polite way to do it is to use javascript to inform the user that they have been have not accessed the site for x amount of time and will be automatically logged out. A good article on how to utilize the javascript timer can be found here http://javascript.about.com/library/weekly/aa073001a.htm
As a precaution, you can also use timestamps in session.
if ((time() - $_SESSION["lastaccessedon"]) > $iTimeoutPeriod)
{
// log user out
}
else
{
$_SESSION["lastaccessedon"] = time();
}