CodeIgniter Forums
Upgraded to 4.4.4, error in Session.php - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: Upgraded to 4.4.4, error in Session.php (/showthread.php?tid=91520)



Upgraded to 4.4.4, error in Session.php - sunchaser - 08-24-2024

Hi, I just upgraded CI to v 4.4.4 and now i get this error:

Code:
CRITICAL - 2024-08-24 09:26:09 --> ErrorException: Undefined global variable $_SESSION
in SYSTEMPATH/Session/Session.php on line 499.
1 SYSTEMPATH/Session/Session.php(499): CodeIgniter\Debug\Exceptions->errorHandler(2, 'Undefined global variable $_SESSION', '/home/***/system/Session/Session.php', 499)
2 APPPATH/Controllers/BaseController.php(69): CodeIgniter\Session\Session->get('character_id')
3 SYSTEMPATH/CodeIgniter.php(914): App\Controllers\BaseController->initController(Object(CodeIgniter\HTTP\CLIRequest), Object(CodeIgniter\HTTP\Response), Object(CodeIgniter\Log\Logger))
4 SYSTEMPATH/CodeIgniter.php(493): CodeIgniter\CodeIgniter->createController()
5 SYSTEMPATH/CodeIgniter.php(361): CodeIgniter\CodeIgniter->handleRequest(null, Object(Config\Cache), false)
6 FCPATH/index.php(79): CodeIgniter\CodeIgniter->run()

any help please?


RE: Upgraded to 4.4.4, error in Session.php - sunchaser - 08-24-2024

The error is caused by a controller I call from cli. I have read in the docs that session stops immediately when cli is used and inside the BaseController I check if exists session(‘character_id’).

How can I solve this, can I check inside the base controller if a call is from cli?

Ok I think I can use: if ($this->input->is_cli_request()) {


RE: Upgraded to 4.4.4, error in Session.php - kenjis - 08-24-2024

See https://www.codeigniter.com/user_guide/general/common_functions.html#is_cli