Welcome Guest, Not a member yet? Register   Sign In
Running session garbage collection with a cron on CI3
#11

(03-28-2022, 10:49 AM)ignitedcms Wrote: If that is indeed the issue and you have set the correct file permissions, I would raise that as bug.

Yeh, perhaps I should. I successfully run this code to delete the session files that are more than 3 days old, so it is evident that file permissions are fine.

PHP Code:
// deal with leftower session files
// can be added to a controller that is publically accessible and run by CRON from time to time
helper('filesystem');
$sfile_message '';
$spath  ROOTPATH '/writable/session/';
$sfiles directory_map($spathtruefalse);
$now  time();
//echo  'before: '; var_dump($sfiles);exit;

foreach ($sfiles as $file) {
 if (
is_file($spath $file)) {
 if (
$now filemtime($spath $file) >= 60 60 24 3) { // 3 days
 
unlink($spath $file);
 
$count_sfiles++;
 }
 }
}
if (
$count_sfiles 0$sfile_message .= '<br> Number of leftower session files removed: ' $count_sfiles// can be sent via email or echoed...

//$files = directory_map($path, true, false);
//echo  'after: '; pre($sfiles);exit; 
==

Donatas G.
Reply
#12

(03-28-2022, 10:49 AM)ignitedcms Wrote: If that is indeed the issue and you have set the correct file permissions, I would raise that as bug.
Strange, I looked at my development server and I see only very recent (5 days) session files. So garbage collector must be at work on my dev environment Smile
==

Donatas G.
Reply
#13

Yeah it is hard to pinpoint, as it depends what versions of PHP etc your development server and your production server is using, and your hosts limitations.

I always have to tweak a few things on my own VPS as it is on shared plan, so there are a few differences, it should just be a case of trial and error with your production environment setup
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply




Theme © iAndrew 2016 - Forum software by © MyBB