Session not working in basecontroller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Session not working in basecontroller (/showthread.php?tid=76424) |
Session not working in basecontroller - hoffmanchan - 05-11-2020 I work on CI4. When I add "$this->session = Services :: session();", I will be get a error message : ( How to slove it, plz ? ) PHP Code: Fatal error: Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at C:\Users\proj\app\Config\Events.php:27) in C:\Users\proj\anaso\system\Debug\Exceptions.php:162 Stack trace: #0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'Cannot modify h...', 'C:\\Users\\proj\\...', 162, Array) #1 C:\Users\proj\anaso\system\Debug\Exceptions.php(162): header('HTTP/1.1 500 In...', true, 500) #2 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException)) #3 {main} thrown in C:\Users\proj\anaso\system\Debug\Exceptions.php on line 162 My BaseController PHP Code: <?php RE: Session not working in basecontroller - nmaa3003 - 05-12-2020 $this->session = \Config\Services::session(); u put wrong namespace. RE: Session not working in basecontroller - hoffmanchan - 05-12-2020 (05-12-2020, 06:24 AM)nmaa3003 Wrote: $this->session = \Config\Services::session(); Wrong namespace ? I have put "use Config\Services" on top. And I have change my code, it still have the error message. Is it something is wrong ? |