I'm having a "weird" issue in a application I'm working on and so far I can't find a fix for this. The application use Symfony2.6.x and relies in several Ajax calls. All the time request are made through Ajax. So, when I login into the app (uses FOSUserBundle) Symfony automatically start a new session, right? Ok, from that moment until the time defined at config.yml
(see config below) for session lifetime the application still working but at some point I got redirected to the login page and session is closed even if I'm actively working on the app. My best approach is that AJAX calls are not taken into account for the lifetime of a session in Symfony or in PHP, I'm right?
My best approach and solution for this issue, do not know if I'm right and neither have tried, I want to listen the opinion of some here in SO, is to regenerate the ID of the session (by calling migrate()
on the current active session) each time an AJAX call is made so this way the session would maintain active, is that approach correct? Any advice around this?
This is my configuration at config.yml for session section:
config.yml
framework:
session:
# session will expire after 10 minutes of inactivity
handler_id: ~
cookie_lifetime: 2400
gc_maxlifetime: 600 # session will expire after 10 minutes of inactivity
gc_probability: 0
gc_divisor: 100
Note: this post and this other from me talks about the same basically but I still not fixing this issue and it's killing my app and my head trying to find a solution.