my environment
Ubuntu 18.04
php-fpm 7.2.24
Apache 2.4.49
My PHP webapp use custom function to delete expired users sessions.
At beginning of main script I something like that:
define("SESSION_SAVE_PATH", "/tmp/my_php_sessions");
define("SESSION_EXPIRE_SECONDS", 36000); // 10h
function session_custom_garbage_collector()
{
if (!is_dir(SESSION_SAVE_PATH)) {
mkdir(SESSION_SAVE_PATH, 0777, true);
}
$files = glob(SESSION_SAVE_PATH . '/sess_*');
$now = time();
foreach ($files as $file) {
if (file_exists($file)) {
$mfile_time = filemtime($file);
if ($now - $mfile_time >= SESSION_EXPIRE_SECONDS) {
unlink($file);
}
}
}
}
session_custom_garbage_collector();
ini_set("session.save_path", SESSION_SAVE_PATH);
sometimes on production environment i see this kind of warning:
PHP Warning: unlink(/tmp/my_php_sessions/sess_7b2v6gipv5riclv1og0b8su9du): No such file or directory in ....
looking at the code above I cannot explain why this happen, it sounds adsurd to me!
Trying to replicate this behaviour on development environment lead me to nothing.
Any suggestions?