Level 2
Thanks everyone. I found the solution: I added:
$response->header("Pragma", "no-cache");
$response->header("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
with Middleware
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
After logging in can't see changes right away
When the user logs in to his account, he does not appear in the header immediately that he entered. He must update the page several times until he writes to him that he is logged in
laravel = 6
php = 7.4
env :
CACHE_DRIVER=memcached
SESSION_DRIVER=file
SESSION_LIFETIME=120
header file :
@guest
<li>
<a href="{{Route('register.customer')}}" class="text-dark"><i class="fa fa-user mr-1"></i> <span>{{ __t('signup') }}</span></a>
</li>
<li>
<a href="{{Route('login.customer')}}" class="text-dark"><i class="fa fa-sign-in mr-1"></i> <span>{{ __t('signin') }}</span></a>
</li>
@endguest
@auth
<li class="dropdown">
<a href="#" class="text-dark" data-toggle="dropdown"><i class="fa fa-home mr-1"></i><span> {{ __t('mydashboard') }}</span></a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
@if (auth()->user()->hasRole('administrator'))
<a href="{{route('admin.home')}}" class="dropdown-item" >
<i class="dropdown-icon icon icon-user"></i> dashboard
</a>
@endif
<a href="{{Route('customer.home')}}" class="dropdown-item" >
<i class="dropdown-icon icon icon-user"></i> {{ __t('profile') }}
</a>
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
<i class="dropdown-icon icon icon-power"></i> {{ __t('logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
@csrf
</form>
</div>
</li>
@endauth
session.php file :
'encrypt' => false,
'files' => storage_path('framework/sessions'),
'connection' => null,
'store' => null,
'lottery' => [2, 100],
'cookie' => 'laravel_session',
'path' => '/',
'domain' => env('SESSION_DOMAIN', 'mydomain.com'),
'secure' => env('SESSION_SECURE_COOKIE', true),
'http_only' => true,
'same_site' => 'none',
Sometimes when pressing logout gives error 419, knowing that csrf is present
Is there any solution to this problem where when he is logged in and he switches it on the main page it gives that he is already logged in
Thanks everyone. I found the solution: I added:
$response->header("Pragma", "no-cache");
$response->header("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
with Middleware
Please or to participate in this conversation.