So, in regards to my problem with sessions and PHP 5.5,
I can reproduce the problem. In the session database driver, the recent change adding the following code is the problem:
PHP Code:
if ($this->_lock === FALSE)
{
return $this->_fail();
}
// Was the ID regenerated?
else
To duplicate the problem, I can simply create a test controller and run it:
PHP Code:
<?php
class Test extends CI_Controller{
public function __construct()
{
parent::__construct();
}
public function index()
{
// This could be below the session regeneration, and still has a problem
$this->load->helper('url');
header( "Location: " . site_url( 'test/redirect_target' ), TRUE, 302 );
$this->session->set_userdata( 'foo', 'bar' );
$this->session->sess_regenerate( TRUE );
}
public function redirect_target()
{
echo '<pre>';
print_r( $_SESSION );
echo '</pre>';
}
}
When the code in the session database driver is in place, "foo" is not shown in the session once redirected.
If the code in the session database driver is commented out, "foo" is shown in the session once redirected.
This is in a new install of CodeIgniter 3.1.3 on Ubuntu 14.04:
PHP Version 5.5.9-1ubuntu4.20
MariaDB version 10.1.20-MariaDB-1~trusty - mariadb.org binary distribution
Database client version: libmysql - mysqlnd 5.0.11-dev - 20120503 - $Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $
There isn't anything special about this LAMP setup, it's just a basic webserver. You're probably not seeing a bunch of people reporting a problem because maybe the database driver is not popular? I can try other PHP 5.5 servers if necessary. PHP 7 works fine for some reason.
Edit --------
After more testing, it seems like the problem is using sess_regenerate with the parameter set to TRUE. I can even do this and instantly have an error with CI 3.1.3:
PHP Code:
<?php
class Test extends CI_Controller{
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->session->set_userdata( 'foo', 'bar' );
$this->session->sess_regenerate( TRUE );
echo '<pre>';
print_r( $_SESSION );
echo '</pre>';
}
}