2023-12-14 23:19:28 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
|
|
|
use Illuminate\Support\Facades\Cookie;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class DisableCookies
|
|
|
|
{
|
|
|
|
|
|
|
|
public function handle(Request $request, Closure $next)
|
|
|
|
{
|
|
|
|
$cookiesAlreadySet = $request->hasCookie(strtolower(config('app.name')).'_session') || $request->hasCookie('XSRF-TOKEN');
|
|
|
|
|
|
|
|
if ($cookiesAlreadySet) {
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
|
2024-02-26 19:50:20 +01:00
|
|
|
Cookie::queue(Cookie::forget(str_replace(' ', '_', strtolower(config('app.name')).'_session')));
|
2023-12-14 23:19:28 +01:00
|
|
|
Cookie::queue(Cookie::forget('XSRF-TOKEN'));
|
|
|
|
config(['session.driver' => 'array']);
|
|
|
|
|
|
|
|
$response = $next($request);
|
|
|
|
$response->headers->remove('Set-Cookie');
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
}
|