By default, Laravel sets a Cookie called [APP_NAME]_session on every request. It's used for features as redirect()->back()
.
This cookie prevents my cache mechanism to work properly (FastCGI, Varnish, you name it)
If I'm one hundred percent sure I won't need it, is there a way to remove this cookie when the user is not auth, without preventing them to log in as usual ?
I'd like to show a different menu when my user is authed, so I can't apply a different middleware on some routes.
I created a new class, which extends the StartSession Middleware (referenced in
app/Middleware/Kernel.php
, inside theweb
group).The two importants part are :
This part prevents the session from being created when the user wasn't already authed.
This part prevents Laravel from setting the cookie as long as the user is not authed.