#StackBounty: #php #session #codeigniter-3 Codeigniter Session resets when refreshing

Bounty: 100

After a month trying to solve this, and trying all kind of answers in related questions I decide to ask it myself.

This problems occurs on a new server we recently bought, the same code it’s working fine on localhost and last server. But it’s probably code related.

The Session is correctly created and the token is set, a var_dump shows that. But when the users tries to login, after redirecting to the access function, the Session token is not set, so the login doesn’t occurs.

Even on the same page, if you refresh, the __ci_last_regenerate (which get the time when the Session was regenerated for last time) is the current time, and change after every single refresh.

In var/lib/php/session two different files are created after every refresh, don’t know why. Here the pic:

enter image description here

The one at 19 secs hast the correct data (time and token), the last one only the time.

Also, we recently add a new subdomain to the site, so we have in the same server two different subdomains.

This is the Session configuration:

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

Tried also with DB driver, and it generated 2 (or 3 rows sometimes) on the table. The config was:

$config['sess_driver']= 'database';
$config['sess_cookie_name']= 'ci_session';
$config['sess_expiration']= 0;
$config['sess_save_path']= 'ci_sessions';
$config['sess_match_ip']= FALSE;
$config['sess_time_to_update']= 300;
$config['sess_regenerate_destroy']= FALSE;
$config['sess_use_database']= TRUE;
$config['sess_expire_on_close']= TRUE;
$config['sess_table_name']= 'ci_sessions';

And the output of database being its columns (id, ip, timestamp, data):

enter image description here

The data is always the same, a last regenerate containing the time and a token in one case, and only the last regenerate in the other (2 rows on each refresh).

PHP is 7.2.7 . CodeIgniter is 3.1.5.

Any further code needed or server information will be supplied if asked.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.