I did not attempt to study your code too closely, but this is what I do...
I set up a timer to go off [i]continuously,[/i] say every 30 seconds or so. And what it would do, in the case of a 3-minute timeout, is to increment a variable. If the variable's value becomes "5," a warning message is displayed to the effect that the session will time-out in 30 seconds.
Meanwhile, there's another little function that's called at strategic places throughout the code, and what it does is to reset that counter to zero. We call this function anytime we do anything useful. (There is a function to do this... we don't diddle with the counter directly, everywhere in our code.)
Now, this of course is an "inactivity timer," but that's basically how session-management typically works: the session dies after so-many minutes of inactivity.
The timer doesn't stop running.
Thank you...do you have a sample?
Nope, but they're out there. Google it. The idea isn't exactly original . . .