What is the artisan command for clearing all session data in Laravel, I\'m looking for something like:
$ php artisan session:clear
But apparent
This thread is quite much old. But I would like to share my implementation of removing all sesssions for file based driver.
$directory = 'storage/framework/sessions';
$ignoreFiles = ['.gitignore', '.', '..'];
$files = scandir($directory);
foreach ($files as $file) {
if(!in_array($file,$ignoreFiles)) unlink($directory . '/' . $file);
}
Why I have not used linux command 'rm'?
Because PHP is one of the prerequisites for Laravel and Linux is not. Using this Linux command will make our project implementable on Linux environment only. That's why it is good to use PHP in Laravel.