Symfony2 sessions do not work as expected / session

My Symfony2 application displays the main page, and from there it mainly uses AJAX requests to display content to the user through modals.

I noticed that after the user has been idle for some time (about 15-30 minutes), the session is destroyed, and the user logs out and he needs to log in again. This is incredibly difficult since I cannot expect users to log in every time they are idle for several minutes.

As far as I can tell, this problem should not occur according to my file config.yml, which looks like this:

framework:
    session:
        cookie_lifetime: 0      # Session lifetime in seconds
        gc_maxlifetime: 28800   # Seconds after which data will be seen
                                # as garbage and potentially cleaned up
        handler_id:  ~          # Current using the default session handler


For completeness, my current environment is as follows:

  • Symfony 2.4.8
  • PHP 5.4
  • : ( php.ini)
  • Ubuntu Server 12.10


:

  • : , .
  • : 15-30 .


?

+4
5

:

, Debian/Ubuntu cronjob, 30 , "" . .

Cronjob , "". Cronjob PHP-CLI script, /usr/lib/php5/maxlifetime, , . script PHP-CLI Symfony2, , gc_maxlifetime cookie_lifetime Symfony2. , session.cookie_lifetime session.gc_maxlifetime /etc/php5/cli/php.ini, 24 . , Symfony2, , .


:

  • cronjob /etc/cron.d/php5,
  • , cronjob
+11

, , cookie , security.yml

security:
    firewalls:
        main:
            form_login:
                remember_me: true
            remember_me:
                key: mycookie
                lifetime: 2592000 # 30 days
                path: /
                domain: ~
                always_remember_me: true
+1

. , .

Symfony ?

symfony:

save_path

type: string default: % kernel.cache.dir%/sessions

, . , , . . .

save_path php.ini, null.

Symfony , ...

+1

symfony:

cookie_lifetime

type: integer default: null

- . null , session.cookie_lifetime php.ini. 0 , cookie .

, 0 , ... .

0

, .

nano/etc/cron.d/php5

, crontab, 30 . script #, , , , #. :

#  Look for and purge old sessions every 30 minutes
#  09, 39, *  * * *  root  @[ -x /usr/lib/php5/maxlifetime ] && [  etc 
   it a long file.....]

2 # Look 09. !

0
source

All Articles