//remove single session
Session::forget('Sessionkey');
//remove multiple sessions
Session::forget(['sessionKey1', 'sessionkey2']);
//remove all sessions
Session::flush();
session()->forget('your_key');
# ref: https://laravel.io/forum/02-06-2014-session-destroy
Session::forget('yourKeyGoesHere') // Removes a specific variable
Session::forget('sessionName')
Session::flush();
Route::get('destory', function () {
session()->forget(['user']);
return redirect('session_get');
});
# ref: https://laravel.io/forum/02-06-2014-session-destroy
Session::forget('yourKeyGoesHere') // Removes a specific variable
@if(Session::has('success'))
<div class="alert alert-success">
{{ Session::get('success') }}
@php
Session::forget('success');
@endphp
</div>
@endif
use IlluminateHttpRequest;
use IlluminateSupportFacadesAuth;
function yourFunctionName (Request $request){
....
Auth::guard('web')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
....
}