Detecting Session Timeout with PHP

Does anyone know how I would go about detecting if a session has timed out using PHP.

Heres an example of what I’d like to be able to do:

[list=1]
[]A user is logged into the system and begins to work filling out a form.
[
]He or she steps away for a while.
[*]Upon returning they attempt to complete their task, but when they submit their form the page recieving the form detects that their session, although once valid, has timed out and redirects them to a login page with an error message informing them they their session has timed out.
[/list]Can someone help me with this?

-adam