How to increase session lifetime in Symfony2?

I set gc_maxlifetime in my config.yml file to 300. But it doesn't work. Symfony2 still accepts the value set in php.ini

Symfony version - 2.4.4

+3


source to share


2 answers


Here is my approach (derived from Drupal config):

  • set the handler to native_file

    (I would use PDOSessionHanlder, but it doesn't seem to be very stable);
  • create a directory seesions

    in a folder app

    ;


config.yml

file:

session:
    handler_id: session.handler.native_file
    cookie_domain: %cookie_domain%
    name: SFSESSID
    cookie_lifetime: 2000000 # change this if you want
    save_path: "%kernel.root_dir%/sessions"
    gc_divisor: 100
    gc_maxlifetime: 200000 # change this if you want
    gc_probability: 1

      

+3


source


Try setting the cookie_lifetime parameters of your session config key.

session:
    cookie_lifetime: 300 # override php.ini config

      



as described here

hope this help

+1


source







All Articles