CakePHP 2.x sessions behaving inconsistently between local dev and production

后端 未结 2 1968
野的像风
野的像风 2020-12-18 15:56

I have a CakePHP 2.x site I\'m working on which performs as intended locally. Login works, session flash messages work, etc. When I push the code to my staging/prod server

2条回答
  •  执笔经年
    2020-12-18 16:47

    In you app/Config/core.php check out these thing.

    1. If you are using SSL and non-SSL based protocols, make sure you have cookie_secure set as false.

      Configure::write('Session', array(
         'defaults' => 'php',
         'ini' => array(
             'session.cookie_secure' => false
         )
      ));
      
    2. Try changing Session's configuration from php defaults to cake or db as

      Configure::write('Session', array(
          'defaults' => 'php', // change 'php' to 'cake' or 'database'
          'cookie' => 'my_app',
          'timeout' => 4320 //3 days
      ));
      
    3. Also try setting Session.checkAgent to false, just for once to ensure if it is a browser issue.

    4. Try changing Session.name of your session, it defaults to 'CAKEPHP'

      Configure::write('Session', array(
          'name' => 'New-Session-name'
          'defaults' => 'php', // change 'php' to 'cake' or 'database'
          'cookie' => 'my_app',
          'timeout' => 4320 //3 days
      ));
      
    5. Remove all cache files from all sub-directories of /app/tmp

    6. Set debug level higher to 1, to do cache refresh. If you still don't see an error, try setting error_reporting to true in php.ini. (Although, this one is very obvious I am still pointing it out in case you might have missed it out)

    Hope this helps

提交回复
热议问题