Spawning a lightbox when session is about to expire

I get complaints from my members that the session timed out before they could finish what they were writing in a form. What is the best way to detect when a session is about to expire? I have some javascript that launches a lightbox, and I would like to this in conjunction with the PHP session expiring code.

Thank you!

Have the javascript pop the lightbox up on a timer (15 minutes by default, so you may want to pop at 13 or 14). Because each pageload would reset both the PHP session expiry and javascript timer, they should be in sync.

Oh. I should probably mention what you should do when they want to continue the session, hah.
Simply have the javascript make an AJAX call to a page on your website (you can create a php page that simply contains <?php session_start(); ?> if you want), and then reset the javascript timer when it receives the response.