2015-04-29 14:37
浏览 35

未定义的变量:_SESSION [CORE / src / Network / Session.php CakePHP 3.0

I am using CakePHP 3.0, and uploaded it to the server, it was working fine in local but somehow after uploading it to server it shows error

Notice (8): Undefined variable: _SESSION [CORE/src/Network/Session.php, line 438]

If any have idea about that please help me. I am still trying to solve it.
I have also tried to put session_start(); in AppController and many other places but then it goes blank.

图片转代码服务由CSDN问答提供 功能建议

我正在使用CakePHP 3.0,并将其上传到服务器,它在本地工作正常,但在上传之后不知何故 到服务器它显示错误

注意(8):未定义的变量:_SESSION [CORE / src / Network / Session.php,第438行]

如果有任何想法,请帮助我。 我仍在尝试解决它。​​
我还尝试将 session_start(); 放在 AppController 和许多其他地方,但随后它变成空白。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

  • dongyan5706 2015-05-11 09:44

    I have found the issue, Its when I was uploading the files to servers it was automatically appending the white blank lines at the end of the AppController and also another controller files.

    So when I removed the blank lines from that files it is working fine again

        //To detect the file which have issue or extra space or early header start
    //File location : vendor/cakephp/cakephp/src/Network/Session.php 
        public function write($name, $value = null)
                    if (empty($name)) {
                    if (!$this->started()) {
                    $write = $name;
                    if (!is_array($name)) {
                        $write = [$name => $value];
                    //remove the comment from bottom line and run your code it will 
                    //show you the exact file from where you have to remove the blank space
                    $data = $_SESSION ?: [];
                    foreach ($write as $key => $val) {
                        $data = Hash::insert($data, $key, $val);
                    $this->_overwrite($_SESSION, $data);

    Small issue but took long time to detect it,hope this will help you all.

    解决 无用
    打赏 举报

相关推荐 更多相似问题