I’m struggling with a session issue so bizarre, I don’t even know how to start debugging it.
I have a CI 3.0.0 project that has been up and running (and constantly being developed) for several years now.
Last week I switched to a new hosting service, and ever since then, I’ve been experiencing session issues, where session data keeps resetting at various intervals.
The switch to the new host was done by the hosting company – they say they copied the whole cPanel account as is, including files & database. One change I did make on the new server is defining the cookie_domain, which was previously unset, to “.mydomain.com”.
When I started having problems with the sessions, I changed it back to $config['cookie_domain'] = '';
but that did not help.
My session/cookie settings in config.php are as follows:
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 14400;
$config['sess_save_path'] = 'ci_sessions3';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
I use sessions mainly to hold user login details, and here’s what I use in my basic page template, to check whether the user is logged on and has the appropriate permissions. If they do, I load the requested page view. If not, I load the login form.
What happens now is that after the user has logged on and started using the system, after a very short time, they are thrown back to the login form, as if the userdata has been somehow reset.
if (!$this->session->userdata('admin_logged_in') || empty($this->session->userdata('digital_view_perms')))
{
$main_content = 'admin_digital/login_form';
}
$this->load->view($main_content, @$data_rows, @$prev_code, @$action);
Any pointers as to where I should start digging for problems would be highly appreciated!
The only thing I know for sure has changed is the hosting service. The php version on the new server is 7.0.28, whereas the php version on the old server was 5.6.33.
Thanks!
3
Answers
I had this problem when I changed the php version to 7.0
Download the latest version of CI3
Replace the
System/
folder by the new one!You need to update your framework to the latest version for it to work with PHP 7
Update your framework! To fix that issue