On Wed 06 Feb 2008, titetluc titetluc wrote:
> The module I am developing has to delete the cookie if it is not refreshed
> regularly.
> The question: how can I manage this timeout inactivity ?
> The best solution would be to use a mechanism where callbacks (deleting the
> cookie rfom the database) would be called automatically on inactivity.
> Does such an API is proposed by :
>      . the APR API
>      . mod_perl API
>      . an Apache2::xxx perl module
>      . a CPAN module
>
> If not, how can I solve my problem ? (I could verify regularly in the DB
> storage, but this is a last resort solution. Even in this case, how could I
> implement it ?)

Apache (at least 2.2.x) implements a "monitor" hook, see server/mpm_common.c. 
To use this hook you'd have to write a bit XS stuff like Geoff's 
AuthenHook, ... since there is AFAIK no CPAN module. This hook is run from 
time to time in the parent apache.

Otherwise there are 2 standard ways to do that:

- a cron job or something similar in the DB itself
- check each time in a connection cleanup handler (to do it not too often you 
can use a global variable that holds the timestamp of the last cleanup and 
run it only if the difference to the current time grows too big.)

I'd go for one of the standard ways since:

- easier to implement
- your code doesn't run as root

Torsten

Reply via email to