简体   繁体   中英

Codeigniter: $_SESSION doesn't work on hosting server

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

$_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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM