Issues

ZF-10700: ( Zend framework 1.11.0 ) Zend_Session_SaveHandler_DbTable, function gc($maxlifetime) issue

Description

Zend/Session/SaveHandler/DbTable.php

line 387-394

public function gc($maxlifetime) { $this->delete($this->getAdapter()->quoteIdentifier($this->_modifiedColumn) . ' + ' . $this->getAdapter()->quoteIdentifier($this->_lifetimeColumn) . ' < ' . $this->getAdapter()->quote(time()));

    return true;
}

my setting


$SessConfig = array( 'save_path' => ROOT. 'temp/sessions', 'name' => 'TestSession', 'cookie_lifetime' => '0', 'gc_maxlifetime' => '300' );

Zend_Session::setOptions($SessConfig);

$config = array( 'name' => 'session', //table name as per Zend_Db_Table 'primary' => 'session_id', //session name 'modifiedColumn' => 'modified', //time the session should expire 'dataColumn' => 'data', //serialized data 'lifetimeColumn' => 'lifetime' //end of life for a specific record );

//Tell Zend_Session to use your Save Handler Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config));

//start your session Zend_Session::start();

Zend framework 1.11.0


the function gc=garbage collector doesn't work! from my setting is gc_maxlifetime = 300 and SessionID record are not active or close browser over 300 second must been deleted by gc function.

but in my DB Session still keep all inactive session and never deleted any session that expired.

anyway, Create new session and update session are wok fine! but never deleted session..

any idea to fixed this issue or anyone can help, please?

PS : I was check code DbTable.php of ZF2 dev.. but code are same. maybe this issue will not been fixed?

Comments

gc() is called by PHP's ext/session, based on a variety of php.ini settings, in particular the "session.gc_*" settings.

That said, in my experience, it's not good to rely on these, and instead to have cron jobs (or similar) that run periodically to call gc() manually.

In closing, this is not a ZF issue, but one with the underlying session extension in PHP.