Today I was working for a client who had an existing codignitor codebase. He needed some enhancement. So I got his code and started setting up on my XAMPP server.
Everything was smooth, database import, config file changes and others. But a strange issue stuck me and cost me 4 hours.
Issue: Codeigniter session lost after refresh or redirect
Strange thing is same code is working on the server.
On page refresh, I echo $this->Session->all_userdata() and I receive:
[__ci_last_regenerate] => 1576624805
Each refresh generates a new number.
The initial session data looks good, as below:
[__ci_last_regenerate] => 1576165611
[DATA] => Array
 => Array
[customer] => 12
[orderqty] => 1
Config settings all looked good.
Digging the internet, I found that there is a REGEX command in the below file that was conflicting due to PHP version mismatch.
//Line 136 changed by me on 12.15.2019 -mb
//OR ! preg_match(‘#\A’.$this->_sid_regexp.’\z#’, $_COOKIE[$this->_config[‘cookie_name’]])
OR ! preg_match(‘/^[0-9a-f]/’, $_COOKIE[$this->_config[‘cookie_name’]])
That solved the issue. Hope this will help someone else.