CakePHP Error: Unable to configure the session, setting session.auto_start failed

后端 未结 5 1964
再見小時候
再見小時候 2021-01-31 19:27

I\'m getting this error:

Error: [CakeSessionException] Unable to configure the session, setting session.auto_start failed.

I\'m using Cakephp 2.2.4.

相关标签:
5条回答
  • 2021-01-31 19:51

    As Andriy's answer says, you should upgrade CakePHP or downgrade PHP. However, if you don't want to or don't have the option to, you need to reconfigure your Cake session so that it uses standard PHP sessions rather than Cake's session.

    app/Config/core.php

    Configure::write('Session', array(
        'defaults' => 'cake', // You need to change the value of this to 'php'
        'timeout' => 120,
        'cookieTimeout' => 20160,
        'checkAgent' => false 
    ));
    
    0 讨论(0)
  • 2021-01-31 20:00

    as I do not have enough reputation to comment, I'm adding the following answer in addition to Simon's one:

    to get it working, I had to comment out all three occurrences of 'session.auto_start' => 0 (around and after line 557 in CakeSession.php)

    For details, see the following patch of the CakePHP team: https://github.com/cakephp/cakephp/commit/faa2cbd3c3fc1bbf83064727847789123110b8e3#diff-bd8dc176fa0f41743dbaafa75f77b5ae

    0 讨论(0)
  • 2021-01-31 20:04

    In PHP version 5.4.19 - developers closed the ability to set session.auto_start option from user script.

    CakePHP removed this option from default session configuration only in 2.4.0 version.

    So you have 3 main option: upgrade CakePHP, downgrade PHP, or use standard php session.

    0 讨论(0)
  • 2021-01-31 20:05

    In your php.ini file, try setting session.auto_start to 1.

    0 讨论(0)
  • 2021-01-31 20:06

    Andriy Struk's answer is correct. He said: So you have 3 main options: upgrade CakePHP, downgrade PHP, or use standard PHP sessions.

    But there's a 4th option, you can simply comment out a single line in /lib/Cake/Model/Datasource/CakeSession.php (around line 557):

    // 'session.auto_start' => 0,
    

    That stops Cake calling ini_set() on that setting, and prevents the fatal error.

    0 讨论(0)
提交回复
热议问题