The array doesn't set a cookie because it is only for the 1 page request and is then forgotten about. Redis, file and any other storage that allows the data to be re-loaded on other requests needs a cookie to know how to get the correct user's session.
There needs to be a cookie in order to identify the user.
There needs to be a cookie in order to identify the user.
Which makes sense for an authenticated user, not for an anonymous, non logged-in user.
For anonymous users, caching should be on for all elements. So, the question is -- where to deal with that.
Even for authenticated users, there's usually some page element / content that can benefit from caching -- for that ESI+caching comes into play. That's a bit further down the road here ...
From my understanding of stripping cookies, PHP (or Laravel) will no longer have access to the cookie, and as such will no longer have access to the Session. So, how do you get around that? Is there a way to make Laravel only set a cookie if the user is logged in?
Is there a way to make Laravel only set a cookie if the user is logged in?
yes.
use the "Session Monster" plugin (https://packagist.org/packages/haifanghui/session-monster)
following install & config
http://abeak.blogspot.com/2014/12/caching-laravel-with-varnish.html
does the trick.
varnish 'HITs' if NOT-logged in; cookie is preserved if AUTH'd.
illuminate/support: 4.2.*
How about L5 / L5.1 ?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community