I am creating an Ajax application in Symfony2 where the user is logged in, and then everything is handled by POST requests from now on. After determining the session lifetime to 5 minutes in config.yml I ran into the problem of invalidating the user session after 5 minutes, even if they make POST requests. Every time a request is made, I would like to reset the countdown before the session is invalid, but I'm not sure how to do this efficiently.
The method I'm thinking of now is to write a listener for the kernel.request event, checking if the request method is POST and manipulating the session class. I havenโt done this yet, but this doesnโt seem like a clean solution, as the listener needs to shoot every time a request is made.
Here is my session configuration:
session: default_locale: %locale% auto_start: true lifetime: 300
Any ideas? Is the solution simple PHP, not Symfony?
source share