I think this is difficult (well I couldn't do it anyway). What did work was a cron job (assuming you are using a unix like operating system) which looks at the last updated time on a session file and triggers a set of actions if the time out criteria are met.
Another approach would be to embed the code you want into say a login script so that while a user is being logged in, the list of sessions is tested for time outs and the relevant code executed.
Hope this helps
Paul