I would do it in an old project.
i named files with session_id (something like: sessionid_some_file.tmp):
_TMP_PATH_: the path by which files are scanned.
foreach(new DirectoryIterator(_TMP_PATH_) as $file)
{
if(preg_match('/(.*)_(.*)_(.*)\.tmp/', $file->getFilename(), $data))
{
session_write_close();
$session_id = $data[1];
session_id($session_id);
session_start();
if(empty($_SESSION))
{
unlink(_TMP_PATH_ . $file->getFilename());
}
}
}
session_write_close();
foreach files i get session_id, open it and check something inside. (I wrote something after opening each session)
But be careful, this piece of code has never been in a production environment.