Symfony 2.1 Session Local Value and Master Value (

2019-07-26 20:27发布

问题:

I'm having problems with sessions when i sarted migration from symfony 2.0 to symfony 2.1.

I'm using simplesamlphp for authentication and everything was working ok on symfony 2.0.

On Symfony 2.1 it is NOT OK. I checked the diferences between them on phpinfo->session and this what i got:

                          symfony2.1         symfony 2.0        Master Value
session.save_handler         user              files                files

session.save_path     (..)/symproject/app   (..)/wamp/tmp      (..)/wamp/tmp
                      /cache/dev/sessions

This values must be equal to php.ini since simplesaml requires it!

I could set the framework:session:save_path property on config.yml but i think this is not a good practice since save path might be diferent depending if im on my local development machine or not (i have my project on git).

And about save_handler i could not find a waay to specify it on config.yml. Am i stick with "user" on this?

What is happening in this symfony version?? In symfony 2.0 this was out of box! Please help. There is no decent documentation on this (believe me i've looked!!).

回答1:

Finally i've got it!

Symfony 2.1 had the Native* drivers by default. And this overrides configurations existing on php.ini.

If you want to use php-ini configs you must pass null to the NativeSessionStorage constructor for the handler arg.

This is done by putting the following configurations on config.yml:

framework:
    session:
        handler_id: ~

More information on this decision can be read here.

This information is missing from symfony docuymentation and upgrade manual.