The function is getting called just fine, that's not the problem. At first I thought it was something with the php settings or cake settings. But the session_save_handlers are pure php, and I have the default settings + nothing cake related is put in between in the gc function.
On Wednesday, August 1, 2012 9:32:38 PM UTC+2, majna wrote: > > By default there is 1% chance for gc to be called by PHP. > If you want to test if gc() is fired, increase *session.gc_probability *close > to *divisor*: > > http://www.php.net/manual/en/session.configuration.php#ini.session.gc-probability > Then watch SQL log for that query. > > Anyway, expires should be current timestamp + Session.timeout config > I know, PHP and sessions - nothing but sorcery :D > > On Wednesday, August 1, 2012 9:12:13 AM UTC+2, Crazy wrote: >> >> I'm having some issues with my sessions. >> >> It's probably configuration somewhere, but don't know what to >> change/where to look. >> >> I'm using database sessions for my cake application, these sessions are >> not getting cleaned up. >> >> The app in question I have the issue on is an old one written on 1.3.10 >> running with php version 5.3.5. The garbage collection function in the 2.x >> branch is the same so don't think the framework version will matter. >> >> I've tracked down the issue to the function __gc located in the >> CakeSession class and that function is registered there in the php >> session_set_save_handler function, this is the function in question: >> >> /** >> * Helper function called on gc for database sessions. >> * >> * @param integer $expires Timestamp (defaults to current time) >> * @return boolean Success >> * @access private >> */function __gc($expires = null) { >> $model =& ClassRegistry::getObject('Session'); >> >> if (!$expires) { >> $expires = time(); >> } >> >> $return = $model->deleteAll(array($model->alias . ".expires <" => >> $expires), false, false); >> return $return; >> } >> >> Now, the comments say that $expires is a timestamp, but this isn't >> correct according to the php docs: >> >> >> gc($lifetime) >> The garbage collector callback is invoked internally by PHP periodically in >> order to purge old session data. The frequency is controlled by >> session.gc_probability and session.gc_divisor. The value of lifetime which >> is passed to this callback can be set in session.gc_maxlifetime. Return >> value should be TRUE for success, FALSE for failure. >> >> The value for $lifeime, so gc_maxlifetime in php.ini is the following: >> >> >> ; After this number of seconds, stored data will be seen as 'garbage' and >> ; cleaned up by the garbage collection process.session.gc_maxlifetime = 3600 >> >> So this results in a query that never deletes anything: >> >> delete from cake_sessions where expires < 3600; >> >> Could someone clarify what I'm doing wrong or if this is an issue in cake >> itself? >> >> >> I've posted this on ask.cakephp.org as well, when I find the answer I'll >> make sure to update both locations. >> >> >> http://ask.cakephp.org/questions/view/database_sessions_garbage_collection_issue >> >> > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php