tags:

views:

32

answers:

1

Hi Everyone,

I have a similar question to this: http://stackoverflow.com/questions/1287064/php-session-timeout-callback

Basically, I want to run some code once a user has been inactive for a certain amount of time. However my case is a little more tricky than the above question. This is because I am using Ajaxterm: http://antony.lesuisse.org/software/ajaxterm/

My php script will handle authentication, and if logged in, will start an ajaxterm daemon. Ajaxterm starts its own little web server, which my php script will "proxy" its output to the user.

What I wish to do is if the user has not pressed a key for a certain amount of time in ajaxterm, to kill the process.

Has anyone got any ideas on how I could do this?

BTW: I could scrap php if there is a better language to do the above in

Thanks

A: 

The question you've posted is not only similar to what you want, it's pretty much the same. I guess you're asking how to do the cleanup task, which consists of killing ajaxterm.

There way I describe here works for Linux, but is portable with a little effort. To identify and kill a process you need to know the process id. You could get it by starting ajaxterm within a bash script, echo the pid and read it out with php. Or even easier use the ajaxterm -PPIDFILE, --pidfile=PIDFILE command line option to set each users ajaxterm instance to a different pidfile. You then just need to read out this file with your language of choice and execute a kill command.

svens
Thanks svens. But I guess my question is, how to know when to kill ajaxterm? If I just used a static timer, it could be killed when the user is still using it.
jtnire
You of course have to adapt it to your website.A quick'n'dirty hack would be to just poll a keep-alive script with ajax every 5mins.
svens
excellent. a javascript call back. thanks
jtnire