dongnao2582 2013-04-05 02:16
浏览 47
已采纳

Codeigniter:$ _SESSION不适用于托管服务器

Code works fine on my localhost but it is giving error when I moved project to hosting server. It says

Severity: Notice  --> Undefined variable: _SESSION

I am using Codeigniter 2.1.3. Double checked $autoload['libraries'] = array('database','session'); in autoload.php

  • 写回答

1条回答 默认 最新

  • dongle2627 2013-04-05 02:55
    关注

    $_SESSION is not available until session_start() is called. I would recommend using the native CI session class function ($this->session->userdata('some_data')) instead of using the default PHP sessions. CI doesn’t use php session’s and instead rely’s on cookies. To amend this notice you can add session_start() to the index.php file if you wish to continue with what you are doing.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?