42 lines
749 B
PHP
42 lines
749 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use File;
|
|
|
|
class ClearSessions extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'clear-sessions';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Clear all session files';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
$files = File::files(storage_path('framework/sessions'));
|
|
|
|
foreach ($files as $file) {
|
|
File::delete($file);
|
|
}
|
|
|
|
$this->info('Session files cleared successfully.');
|
|
|
|
return 0;
|
|
}
|
|
}
|