简体   繁体   中英

Setting up Zend Framework DB garbage collection in application.ini? (and bootstrap ?)

I'm storing all my sessions into the database with this in the application.ini

/* Session */
resources.session.use_only_cookies = on
resources.session.gc_maxlifetime = 864000
resources.session.remember_me_seconds = 864000
resources.session.cookie_lifetime = 864000
resources.session.name= "sessionName"

resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable"

resources.session.saveHandler.options.name = "sessions"
resources.session.saveHandler.options.primary = "id"
resources.session.saveHandler.options.modifiedColumn = "modified"
resources.session.saveHandler.options.dataColumn = "data"
resources.session.saveHandler.options.lifetimeColumn = "lifetime"

The expired session aren't being deleted in the database. What am I missing? Should there be something in the bootstrap? If anyone can help it would be appreciated. Thank you.

It looks like an expired session is deleted from the database when the session is read or when destroy is called.

//from Zend_Session_SaveHandler_DbTable
 public function read($id)
    {
        $return = '';

        $rows = call_user_func_array(array(&$this, 'find'), $this->_getPrimary($id));

        if (count($rows)) {
            if ($this->_getExpirationTime($row = $rows->current()) > time()) {
                $return = $row->{$this->_dataColumn};
            } else {
                $this->destroy($id);
            }
        }

        return $return;
    }


 public function destroy($id)
    {
        $return = false;

        if ($this->delete($this->_getPrimary($id, self::PRIMARY_TYPE_WHERECLAUSE))) {
            $return = true;
        }

        return $return;
    }

There may be other instances where the database record is removed but I haven't located them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM