Summer Su
Summer Su

Reputation: 289

Destroy the session file in Laravel

As we all know, we can use the function session_destory() to delete the session file in PHP.But I do not know how to delete session file in Laravel due to the reason that the author rewrites the session module. Expecting your answers.

Upvotes: 0

Views: 7654

Answers (5)

DEEPAK
DEEPAK

Reputation: 1504

If you have set the session storage option in files and if you finding difficulties flushing sessions from coding , It happens sometime . Then you ultimate solution go directly to the files where it is being stored and delete the file and you see your all session will be gone for good.

session files are stored in following path with random chars.

yourfoldername/storage/framework/sessions/

Upvotes: 0

Summer Su
Summer Su

Reputation: 289

I find the answer by reading the original code in laravel framwork!

session()->getHandler()->destroy();

I hope it will help others.

Upvotes: 0

Bhupendra Mistry
Bhupendra Mistry

Reputation: 628

You have to use Session flush as shown below:

Session::flush(); // destroy all the session.

Upvotes: 1

Kuldeep Mishra
Kuldeep Mishra

Reputation: 4040

Just use this

Session::flush();

in Laravel to destroy all the session.

Upvotes: 1

Sapnesh Naik
Sapnesh Naik

Reputation: 11636

A handy route I use while in development only:

Route::get('/flush', function () {
    Session::flush();
    return redirect('/login');
})->name('flush');

Upvotes: 2

Related Questions