Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7606543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:26:07+00:00 2026-05-31T00:26:07+00:00

I have an application in Zend where I need to implement system which will

  • 0

I have an application in Zend where I need to implement system which will log users work time to database. There is id_worktime, id_user, login_time and logout_time. Logging in and logging out is easy, but there is problem when user doesn’t do anything longer than gc_maxlifetime. I wrote class extending Zend_Session_SaveHandler_DbTable where i 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 as $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 I hit refresh from other web browser – old rows in session table are deleted and logout_time is updated in worktime table. But when I hit refresh in web browser where user was logged in (session is expired now of course) nothing is put into worktime and row in session is updated – column ‘modified’ is set to current time and ‘data’ is equal to:

SessionPreferencesFlag|a:1:{s:16:"sessionSavedInDb";b:1;}

(before there was Zend_Auth object and a lot more, among others id_worktime which i need).

And now THE question – what part of Zend Framework clears that session row? I suppose it’s something in Zend_Session, but I really can’t find it. Some help, please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:26:09+00:00Added an answer on May 31, 2026 at 12:26 am

    Zend_Session builds on the built-in PHP session functionality, so the garbage collection method is called by PHP itself where appropriate.

    If you take a look at the source code for Zend_Session_SaveHandler_DbTable, I think your problem is that in the read() method there, if it successfully loads a session out of the DB but finds it has expired, it calls destroy(), deleting the session data. This ‘bypasses’ the code you have to update the work time when sessions are deleted via. garbage collection. I’d suggest moving the bulk of your code to another method which you call from gc(). You can then also extend the destroy() method to get it to call the new method as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have build a web application in Zend Framework and now desperately need a
I have a Zend Application with user authentication. I need the UserID in nearly
I ran across an interesting issue today. We have an application that utilizes Zend
I have a Zend Framework application structure as below: /application /library /Zend /Core /Filter
I have a PHP MVC application using Zend Framework. As presented in the quickstart,
My setup: Ubuntu LAMP, application built w/ zend framework My Problem: I have a
All, I have a PHP Web application built using Zend Framework and MVC with
I'm building a web application using PHP5.3 and Zend Framework 1.9.4. i have an
I have application which needs to use a dll (also written by me) which
I have a Zend_Framework application, which has a whole bunch of model classes. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.