CodeIgniter: ini_set(): A session is active. You cannot change the session module's ini settings at this time

I’m using the session database driver on a MariaDB database and getting the error message ini_set(): A session is active. You cannot change the session module's ini settings at this time emanating from this line of code. I’m yet to fathom why the session write is failing in the first place, but I’m guessing the ini_set message is the result of a bug?

CI version: 3.1.9
OS: CentOS 7.5
Apache/PHP-FPM
PHP 7.2.14 (cli) (built: Jan 11 2019 10:01:17) ( NTS )
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.14, Copyright (c) 1999-2018, by Zend Technologies

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 32 (21 by maintainers)

Commits related to this issue

Most upvoted comments

Just change constant variable called ENVIRONMENT to production located on index.php. Problem solved LOL

I had this issue with CI version 3.1.10 and 3.1.11 on PHP 7.1 or 7.2 using files or database driver. I later found out that the issue was to do with having a blank line spacing before the starting <php> tag in my controller files. When I removed that space, everything is working fine now. Phew, had to research and troubleshoot for almost 6 hours …😃

@Paradinight If that was the case, a different error would occur, saying a session can’t be started in the first place. Pay attention. 😃

@jamieburchell Someone opened another issue, which contradicts this one; see #5715 - write() fails, but there’s no warning about ini_set() during an active session, and it’s also on PHP 7.2.