• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Session issue with CI Environment set to Testing (CI4)

#1
I was having trouble setting up session data and retrieve them in other files. After a lot of trial and error, I found out that was because of the CI_ENVIRONMENT set to 'testing' in .env file. When this was set to either 'development' or 'production', this was working all fine.

Upon investigating the matter, this is the piece of code I found in Session.php file.

protected function startSession()
    {
        if (ENVIRONMENT === 'testing')
        {
            $_SESSION = [];
            return;
        }

        // @codeCoverageIgnoreStart
        session_start();
        // @codeCoverageIgnoreEnd
}


So essentially, for 'testing' environment, it is setting session to null and hence session data was not available. Can somebody let me know why session is set to null in here? What is the reason behind this?
Reply

#2
Looks like a bug to me, you should open an issue on GitHub
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.