function session_cache_file_cron in Session Cache API 8
Same name and namespace in other branches
- 7 session_cache_file/session_cache_file.module \session_cache_file_cron()
Implements hook_cron().
File
- session_cache_file/
session_cache_file.module, line 85 - session_cache_file.module
Code
function session_cache_file_cron() {
$session_cache_root = session_cache_file_directory();
if (empty($session_cache_root)) {
return;
}
if ($bin_dirs = scandir($session_cache_root)) {
foreach ($bin_dirs as $bin_dir) {
if (strpos($bin_dir, '.') !== 0) {
if ($filenames = scandir("{$session_cache_root}/{$bin_dir}")) {
foreach ($filenames as $filename) {
if (strpos($filename, '.') !== 0) {
$filespec = "{$session_cache_root}/{$bin_dir}/{$filename}";
$last_modified = filemtime($filespec);
if ($last_modified && time() - $last_modified > SESSION_CACHE_DEFAULT_EXPIRATION_DAYS * 24 * 60 * 60) {
if (!@unlink($filespec)) {
drupal_set_message(t('Could not delete expired session cache file %file.', array(
'%file' => $filespec,
)), 'warning');
}
}
}
}
}
}
}
}
}