Re: Trigger an action on session timeout - feature request?

From: Date: Mon, 12 Nov 2007 21:19:11 +0000
Subject: Re: Trigger an action on session timeout - feature request?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-264395@lists.php.net to get a copy of this message
Is there any possibility to trigger an action when the session is inactive for some time? I need to log users' login and logout, and so I need to know about logouts caused by timeout. Neither there seems to be a possibility of a workaround like walking through all my sessions for timeouted ones and destroy them myself.
if you want it server side, it would have to be some kind of scheduled job (cron, etc). Most banks have session timeouts using javascript or asp, client side. You do this with php by putting the session timeout duration into javascript, then a settimeout and if browser closed... etc.. the default in php.ini is 24 minutes... u can use this, or use any value...... then have logout.php clean up <?php $timeout = ini_get('session.gc_maxlifetime') * 1000 // convert from seconds to milliseconds for javascript; ?> <html> <head> <script type="text/javascript"> <!-- setTimeout("window.location = 'logout.php'",<?php echo $timeout?>); // --> </script> </head> <body> </body> </html>

« previous php.general (#264395) next »