Re: [PHP] Trigger an action on session timeout - feature request?
On Nov 12, 2007 3:19 PM, Jake <[EMAIL PROTECTED]> wrote: > >> 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 > > > $timeout = ini_get('session.gc_maxlifetime') * 1000 // convert from > seconds > to milliseconds for javascript; > > ?> > > > > > > > > > > > To add onto this... you may want to update the timeout each time the user takes an action (onclick, onmousemove, etc). This way, if a user is reading a long contract on his bank statement (for example), then it won't automatically close the page - quite frustrating! =D ~Philip
Re: [PHP] Trigger an action on session timeout - feature request?
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 $timeout = ini_get('session.gc_maxlifetime') * 1000 // convert from seconds to milliseconds for javascript; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Trigger an action on session timeout - feature request?
Hi, this is obvious and is not related to the problem. I meant something completely different - launch an action when PHP timeouts/destroys particular session. Regardless of whether the user accesses the page or not. (E.g. for the need to close some records in database, but that's not important) Tomas > You could simply validate the user with > > session_start(); > $tbaged = false; > if (isset($_SESSION['user_id'])) { >$user = new User($_SESSION['user_id']); >$tbaged = true; > else { >$login = $_REQUEST['screename']; >$password = $_REQUEST['pword']; >$login = clean($login); >$password = clean($pword); >$user = checkLogin($login,$pword); >if (!is_null($user)) { > $tbaged = true; >} > } > > if (!$tbaged) { >session_destroy(); >die("You are not logged in."); > } > > > > > -Original Message- > From: Tomas Telensky [mailto:[EMAIL PROTECTED] > Sent: Monday, November 12, 2007 12:20 PM > To: php-general@lists.php.net > Subject: [PHP] Trigger an action on session timeout - feature request? > > > Hi, > > 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. > > I have searched through the PHP doc and didn't found anything. So probably > this is a feature request. Where should I post it? PHP's bug reporting > system, > unlike many common bug reporting systems, doesn't seem to distinguish > between bugs and feature requests. > > I think this concept of being possible to define something like > custom "session destructor" is obvious and useful enough to be worth > implementing to PHP. > > Thanks for help, > > Tomas > > -- > "No Software Patents!" -- Allowing patents over software ideas will > seriously affect the Creativity, Productivity and Freedom of all. > Link: http://www.nosoftwarepatents.com/ > -- > Defend your freedom by signing a petition. > Link: http://petition.eurolinux.org/index_html?LANG=en > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- "No Software Patents!" -- Allowing patents over software ideas will seriously affect the Creativity, Productivity and Freedom of all. Link: http://www.nosoftwarepatents.com/ -- Defend your freedom by signing a petition. Link: http://petition.eurolinux.org/index_html?LANG=en -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Trigger an action on session timeout - feature request?
You could simply validate the user with session_start(); $tbaged = false; if (isset($_SESSION['user_id'])) { $user = new User($_SESSION['user_id']); $tbaged = true; else { $login = $_REQUEST['screename']; $password = $_REQUEST['pword']; $login = clean($login); $password = clean($pword); $user = checkLogin($login,$pword); if (!is_null($user)) { $tbaged = true; } } if (!$tbaged) { session_destroy(); die("You are not logged in."); } -Original Message- From: Tomas Telensky [mailto:[EMAIL PROTECTED] Sent: Monday, November 12, 2007 12:20 PM To: php-general@lists.php.net Subject: [PHP] Trigger an action on session timeout - feature request? Hi, 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. I have searched through the PHP doc and didn't found anything. So probably this is a feature request. Where should I post it? PHP's bug reporting system, unlike many common bug reporting systems, doesn't seem to distinguish between bugs and feature requests. I think this concept of being possible to define something like custom "session destructor" is obvious and useful enough to be worth implementing to PHP. Thanks for help, Tomas -- "No Software Patents!" -- Allowing patents over software ideas will seriously affect the Creativity, Productivity and Freedom of all. Link: http://www.nosoftwarepatents.com/ -- Defend your freedom by signing a petition. Link: http://petition.eurolinux.org/index_html?LANG=en -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Trigger an action on session timeout - feature request?
Hi, 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. I have searched through the PHP doc and didn't found anything. So probably this is a feature request. Where should I post it? PHP's bug reporting system, unlike many common bug reporting systems, doesn't seem to distinguish between bugs and feature requests. I think this concept of being possible to define something like custom "session destructor" is obvious and useful enough to be worth implementing to PHP. Thanks for help, Tomas -- "No Software Patents!" -- Allowing patents over software ideas will seriously affect the Creativity, Productivity and Freedom of all. Link: http://www.nosoftwarepatents.com/ -- Defend your freedom by signing a petition. Link: http://petition.eurolinux.org/index_html?LANG=en -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php