You could try something like this -
<?php
$path_to_sessions = '/tmp/';
if ($handle = opendir($path_to_sessions)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && !is_dir($path_to_sessions.$file)) {
unlink($path_to_sessions.$file);
}
}
closedir($handle);
}
?>
Be careful to get the directory correct.