![]() |
Codeigniter 3.1.11 - Session regenerate and data loss PHP 7.3.11 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: Codeigniter 3.1.11 - Session regenerate and data loss PHP 7.3.11 (/showthread.php?tid=75042) |
Codeigniter 3.1.11 - Session regenerate and data loss PHP 7.3.11 - reesethebeast - 12-12-2019 I am using Codeigniter 3.1.11 on my localhost with XAMPP PHP version 7.3.11. I am using database sessions, not file. I wrote some simple code to put user cart data into the session. On the initial form submission, the data is put in the session and looks good. On refresh, the session is regenerated and the prior session data is not there in the new session but is still there in an old session. Below are my config settings. I tried many combinations and cannot figure out the issue. Why does the session regenerate even when I set to FALSE? On page refresh, I echo $this->Session->all_userdata() and I receive: Code: Array Each refresh generates a new number. The initial session data looks good, as below: Code: Array Config settings Code: $config['sess_driver'] = 'database'; RE: Codeigniter 3.1.11 - Session regenerate and data loss PHP 7.3.11 - reesethebeast - 12-16-2019 I guess I will answer this myself then. I got this partially working by applying a solution from another thread where the REGEX was incorrect when checking the cookie. However this only partially works or works sometimes. This logic is not always executed so I think there is another place in the standard CI session code which also needs to be changed. \system\libraries\session\Session.php //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']]) RE: Codeigniter 3.1.11 - Session regenerate and data loss PHP 7.3.11 - InsiteFX - 12-16-2019 Why not save the users cart on there system using a secure cookie or to the database? RE: Codeigniter 3.1.11 - Session regenerate and data loss PHP 7.3.11 - reesethebeast - 12-16-2019 (12-16-2019, 01:17 PM)InsiteFX Wrote: Why not save the users cart on there system using a secure cookie I am using session in DB, I do not want to post to another database table as users are not logged in so I would need to determine which order belongs to which online user, which is what the session is for. RE: Codeigniter 3.1.11 - Session regenerate and data loss PHP 7.3.11 - steveolateru - 01-28-2020 This is usually caused by incompatibility between Codeigniter and PHP versions. For example, running Codeigniter version 3.1 on PHP 7.3.11 will result in unexpected behaviours like session regeneration. Try upgrade to latest Codeigniter version, it should resolve the issue. RE: Codeigniter 3.1.11 - Session regenerate and data loss PHP 7.3.11 - garabudas - 06-19-2020 hi, i know this reply is late, I also had this same problem with shopping cart and sessions and even some of my function calls were not working. I noticed that for every request(or function call) I make there was no cookie request, and after a lot of reading, I learned that it is usually a URL setting in our CI app. initially my $config['base_url'] looked like this: 'https://site.domain.com' what I did was change it to 'https://www.site.domain.com' and the cookie requests were now included in every function call and the session is behaving as it should. hope this helps RE: Codeigniter 3.1.11 - Session regenerate and data loss PHP 7.3.11 - marcsinfo - 07-26-2021 Thanks @garabudas for this. But, it didn't work for us on CI3.1.11 & PHP 7.2.34. Any other changes were done along with this simple change of 'base_url' in config file? |