Search code examples
phpsymfonysessionfosuserbundleovh

Lost session with Symfony 2.8 on ovh mutualized server


I use Symfony 2.8 with FOSUserBundle 2. I have upgraded my offer on ovh and some elements of my php configuration changed. I have a big problem because my users can't connect to the website (it disconnects after about 5 minutes). It's the website of an association that counts with about 8000 members and every member can connect... Before, the session wrote in a special folder (app/var/session). Know it should write in the cache folder but it doesn't.

I have an htaccess in the www folder and in the project folder that contains :

SetEnv SHORT_OPEN_TAGS 0
SetEnv REGISTER_GLOBALS 0
SetEnv MAGIC_QUOTES 0
SetEnv SESSION_AUTOSTART 0
SetEnv ZEND_OPTIMIZER 1
SetEnv PHP_VER 5_6

in my config.yml, I have :

    session:
        cookie_lifetime: ~
        # handler_id: session.handler.native_file
        # save_path: '%kernel.root_dir%/var/sessions'

As information, this is part of my composer.json :

"require": {
    "php": ">=5.3.9",
    "symfony/symfony": "2.8.*",
    "doctrine/orm": "^2.4.8",
    "doctrine/doctrine-bundle": "~1.4",
    "twig/extensions": "1.4.*",
    "symfony/assetic-bundle": "2.8.*",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.11.3",
    "sensio/distribution-bundle": "~5.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "sensio/generator-bundle": "~3.0@dev",
    "incenteev/composer-parameter-handler": "~2.0",
      "symfony/dom-crawler" :"3.2.*",
    "friendsofsymfony/user-bundle": "~2.0@dev",
    "gregwar/image-bundle": "dev-master"
},
"require-dev": {
    "leafo/lessphp": "0.5.0",
    "sensio/generator-bundle": "~3.0",
    "symfony/phpunit-bridge": "~2.7"
},

My cache and my logs folders are in chmod -R 777 It works perfectly (it means the session file is created in the cache folder) when I deploy on my local computer. It still doesn't work (meaning the session file is not created) if I enter though direct url instead of www.mydomain.com (so it's not a problem of ovh multisites configuration). It also doesn't work when I am in dev environment. If I look in the logs, I don't see any error.
For sure, there is a php misconfiguration. Am I missing some important php variable set ? Any Idea ?
Thanks a lot.


Solution

  • As I couldn't make it work , I finally discovered I can manage sessions in database using pdo handler. I am not convinced it's the best solution, but ilt still is a solution. For further explanation have a look at symfony doc pdo_session_storage