Welcome Guest, Not a member yet? Register   Sign In
session data keeps resetting
#1

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:

PHP Code:
$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.


PHP Code:
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!

As I said, the only thing I know for sure has changed is the hosting service. But how can that affect sessions?

Thanks!

einav
Reply
#2

@einav,
Have you checked your PHP session settings? Is the PHP version that you are now using different then the previous version?
Reply
#3

(03-26-2018, 08:00 AM)php_rocs Wrote: @einav,
Have you checked your PHP session settings? Is the PHP version that you are now using different then the previous version?

Thanks for the pointers.

Yes. I now see the new server is PHP 7.0.28, whereas the old one was 5.6.33. Should that make a difference in this regard?

As for the PHP session settings, I looked under cPanel's MultiPHP INI Editor, and the settings seem identical in both servers. Anywhere else I should look for session settings?
Reply
#4

I would also upgrade to the new CodeIgniter 3.1.8

Also make sure that you wipe out the old session data in your database and start new.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(03-26-2018, 09:29 AM)InsiteFX Wrote: I would also upgrade to the new CodeIgniter 3.1.8

Also make sure that you wipe out the old session data in your database and start new.

How would you recommend I should do the upgrade? Is there a combined changelog from 3.0.0 to 3.1.8, or do I have to go step by step over the 15 upgrade notes from then till now?

Is the 3.0.0 version incompatible with php 7, and do you think this is what's causing the session issue?

Also - what do you mean by wiping old session data? delete the contents of the ci_session table in mySql?
Reply
#6

(03-26-2018, 10:49 AM)einav Wrote: How would you recommend I should do the upgrade? Is there a combined changelog from 3.0.0 to 3.1.8, or do I have to go step by step over the 15 upgrade notes from then till now?
You need to open all upgrades notes and follow them. But just add the latest system folder, no need to replace it every time.

(03-26-2018, 10:49 AM)einav Wrote: Is the 3.0.0 version incompatible with php 7, and do you think this is what's causing the session issue?
It is.
https://www.codeigniter.com/userguide3/c...-for-3-0-3

(03-26-2018, 10:49 AM)einav Wrote: Also - what do you mean by wiping old session data? delete the contents of the ci_session table in mySql?
Yes
Reply
#7

I would like to tell you that you wipe out the old session data in your database and start new.
No SEO spam!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB