What is the artisan command for clearing all session data in Laravel, I\'m looking for something like:
$ php artisan session:clear
But apparent
UPDATE: This question seems to be asked quite often and many people are still actively commenting on it.
In practice, it is a horrible idea to flush sessions using the
php artisan key:generate
It may wreak all kinds of havoc. The best way to do it is to clear whichever system you are using.
The Lazy Programmers guide to flushing all sessions:
php artisan key:generate
Will make all sessions invalid because a new application key is specified
The not so Lazy approach
php artisan make:command FlushSessions
and then insert
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use DB;
class flushSessions extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'session:flush';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Flush all user sessions';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
DB::table('sessions')->truncate();
}
}
and then
php artisan session:flush
I know this is an old thread, but what worked for me is just remove the cookies.
In Chrome, go to your develop console, go to the tab "Application". Find "Cookies" in the sidebar and click on the little arrow in front of it. Go to your domainname and click on the icon next to the filter field to clear the cookies for your domain. Refresh page, and all session data is new and the old ones are removed.
If you are using file based sessions, you can use the following linux command to clean the sessions folder out:
rm -f storage/framework/sessions/*