php - What part of Zend Framework is cleaning session object when lifetime is over? -


i have application in zend need implement system log users work time database. there id_worktime, id_user, login_time , logout_time. logging in , logging out easy, there problem when user doesn't longer gc_maxlifetime. wrote class extending zend_session_savehandler_dbtable override gc() method:

class vao_session extends zend_session_savehandler_dbtable {    public function gc($maxlifetime) {     $garbage = $this->fetchall($this->select()->from('session')->where('`modified` + `lifetime` < ?', time()));      foreach ($garbage $session)     {         $variables = array();         $a = preg_split("/(\w+)\|/", $session['data'], -1, preg_split_no_empty | preg_split_delim_capture);         for($i = 0; $i < count($a); $i = $i + 2){             $variables[$a[$i]] = unserialize($a[$i + 1]);         }          if (isset($variables['worktime']))         {             $worktime = $variables['worktime'];             $idworktime = $worktime['id_worktime'];              if ($idworktime)             {                 $date = new zend_date($session['modified']);                 $data['logout_time'] = $date->tostring(zend_date::iso_8601);                 $worktimetable = new application_model_dbtable_worktime();                 $worktimetable->update($data, 'id_worktime = '.$idworktime);             }         }     }      parent::gc($maxlifetime); } } 

it works ok when hit refresh other web browser - old rows in session table deleted , logout_time updated in worktime table. when hit refresh in web browser user logged in (session expired of course) nothing put worktime , row in session updated - column 'modified' set current time , 'data' equal to:

sessionpreferencesflag|a:1:{s:16:"sessionsavedindb";b:1;} 

(before there zend_auth object , lot more, among others id_worktime need).

and question - part of zend framework clears session row? suppose it's in zend_session, can't find it. help, please?

zend_session builds on built-in php session functionality, garbage collection method called php appropriate.

if take @ source code zend_session_savehandler_dbtable, think problem in read() method there, if loads session out of db finds has expired, calls destroy(), deleting session data. 'bypasses' code have update work time when sessions deleted via. garbage collection. i'd suggest moving bulk of code method call gc(). can extend destroy() method call new method well.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -