Closed MatusMak closed 6 years ago
An update - by accident, I discovered that it is barryvdh/laravel-debugbar that is causing this issue. When I uninstalled it, everything started to work correctly. My bad for not trying this out sooner, I thought it was my friend, not enemy.
NOTE: I have seen a lot of issue related to Session, but this it is not browser, OS or PHP related and I also reproduced it on a fresh Laravel installation. I have also already asked for help on StackOverflow but nobody knew the solution.
I have a very weird issue that we faced during development. Once my session expires due to not being refreshed for too long, a new session will be created as expected. However, if I am browsing on public site (which is not under Auth protection), the session will not persist and with each get/post request, it will be ignored and a new one will be created (I can see that on XRSF token and new file being created in storage/framework).
Here are few scenarios:
If no user is logged in, everything works fine.
If admin user is logged in (with "Remember me" being checked), but public user is not, accessing any public (unprotected) route (which uses default
web
middleware) will recreate session as described above. However, once I access any route underadmin
middlware (web
middleware + auth check), session will stick and after that, the issue for public route disappears.If both users are logged in and I access any protected route, session sticks immediately.
I tried the following, without any success:
web
middleware isn't applied twice to any routeWhat resolves the issue:
Environments where I reproduced the issue:
My PC
My laptop
Colleague's laptop
Free hosting (Endora.cz)
What probably does not cause the issue:
What might caused the issue:
Steps to reproduce (ONLINE):
On this environment, SESSION_LIFETIME was set to 1 so it can be quickly reproduced.
You can download this demo here from BitBucket
Here are some files that might be useful for you:
.env
RouteServiceProvider.php
routes/public.php
routes/admin.php
Http/Kernel.php
AuthMiddlware.php