- db_update('wfpl_sessions', 'expires', $expires, 'where id=%i', $GLOBALS['session_id']);
+# update the idle_timeout
+function session_touch() {
+ if(!session_exists()) {
+ return;
+ }
+ # is the session extendable?
+ if ($GLOBALS['wfpl_session']['expires'] < $GLOBALS['wfpl_session']['expires_max']) {
+ # would this extend the session by at least 10%?
+ $now = time();
+ $session_start = $GLOBALS['wfpl_session']['expires'] - $GLOBALS['wfpl_session']['idle_timeout'];
+ if ($now > $session_start + ceil(0.1 * $GLOBALS['wfpl_session']['idle_timeout'])) {
+ $expires = max(
+ $GLOBALS['wfpl_session']['expires_max'],
+ $now + $GLOBALS['wfpl_session']['idle_timeout']
+ );
+ db_update('wfpl_sessions', 'expires', $expires, 'where id=%i', $GLOBALS['wfpl_session']['id']);
+ }
+ }