I am trying to use Zend_Session_Handler_DbTable to save my session data to the db but as far as i can see, the expired sessions are never deleted from the database.
I can see a cron job running (ubuntu) which deletes the file based sessions but I couldn’t find how gc works on sessions which are saving in db.
The
Zend_Session_SaveHandler_DbTableclass has a garbage collection method calledgcwhich is given to PHP viasession_set_save_handlerwhen you callZend_Session::setSaveHandler().The
gcfunction should get called periodically based on the php.ini valuessession.gc_probabilityandsession.gc_divisor. Make sure those values are set to something that would result in garbage collection running at some point.Also make sure you specify the
modifiedColumnandlifetimeColumnoptions when creating the DbTable save handler because the defaultgcfunction uses those columns to determine which rows in the session table are old and should be deleted.