I'm using Symfony 2.3 LTS.
I can fully use the remember_me
feature in Symfony, including setting it and logging back in after session expiry. However my issue is that once the user is logged back in with the remember_me
feature then the expiry isn't refreshed.
In other words, if you set the "lifetime" of the remember_me
cookie to 14 days then regardless of how many time the user visits the site they will always need to re-authenticate with a full username/password (after 14 days.) I don't want to set a longer cookie as 14 days without visiting seems right.
I know how to manually set the remember_me
cookie. I just need to know where to put that code.
I've tried these:
This SO question doesn't do what I want and is very different.
There doesn't appear to be any settings in the
security.yml
configuration (to refresh expiry.)Hooking in on the
processAutoLoginCookie
method inSymfony\Component\Security\Http\RememberMe\TokenBasedRememberMeServices
, but that can't work as there's no access to a Response (to set the cookie manually.)Listening on the
SecurityEvents::INTERACTIVE_LOGIN
event looks a good idea, butInteractiveLoginEvent
doesn't have access to the Response either. Here's an example.I could get messy by setting a request attribute using one of the above and then setting a response listener to detect for that, but I think that's too messy. There must be a better way to do it.
I could use one of the above to listen on the request, generate a response (e.g. redirect), set the cookie, perform the redirect, but again that's not good enough.