Codeigniter 3.0-dev drops sessions randomly

This is the project I inherited, it says: define ('CI_VERSION', '3.0-dev'); at CodeIgniter.php. This is an e-commerce site and every time a customer complains that they are logged out and their cart contents are empty accidentally. It seems like it happens over and over again for the same client on the same day, but not for anyone else. The same client can try again a few days later from the same machine and browser and have no problem at all. A customer complained about this yesterday and I found 7 different sessions for their IP address on the same day in the ci_sessions table. Since I can never reproduce the problem myself, I find it hard to figure it out. I read several posts on the internet about CI sessions and I did all the suggested updates for the config values ​​I found hopingthat it would be fixed, only for another customer to complain about the same thing again a couple of weeks later. If you are facing this problem, perhaps you can suggest another solution?

Here are some of my settings:

$config['sess_cookie_name']     = 'pyrocms' . (ENVIRONMENT !== 'production' ? '_' . ENVIRONMENT : '');
$config['sess_expiration']      = 0;
$config['sess_expire_on_close'] = true;
$config['sess_encrypt_cookie']  = true;
$config['sess_use_database']    = true;
// don't change anything but the 'ci_sessions' part of this. The MSM depends on the 'default_' prefix
$config['sess_table_name']      = 'default_ci_sessions';
$config['sess_match_ip']        = true;
$config['sess_match_useragent'] = true;
$config['sess_time_to_update']  = 300;

$config['cookie_prefix']    = (substr_count($_SERVER['SERVER_NAME'], '.') > 1) ? substr($_SERVER['SERVER_NAME'], 0, strpos($_SERVER['SERVER_NAME'], '.')) . '_' : 'default_';
$config['cookie_domain']    = ($_SERVER['SERVER_NAME'] == 'localhost') ? '' : $_SERVER['SERVER_NAME'];
$config['cookie_path']      = BASE_URI;
$config['cookie_secure']    = false;

$config['global_xss_filtering'] = false;

      

+3


source to share


2 answers


A customer complained about this yesterday and I found 7 different sessions for their IP on the same day in the ci_sessions table.

This appears to be a bottleneck as new sessions are created for the user; also causes an ad cart to appear (think cart is based on $_SESSION

which is regenerated / destroyed and created).

Since I can never reproduce the problem myself, I find it hard to figure it out.



The client can use private browsing. Try to delete all cookies from your browser (system) to reproduce it. The linked post might also help you: Remembering PHP Session Private Browsing

However, there are some fuzzy feelings about these two lines. Why don't you zoom sess_expiration

up $config['sess_expiration'] = 60 * 60 * 24;

and sess_expire_on_close

up$config['sess_expiration'] = false;

+1


source


Try to install $config['sess_match_ip'] = "FALSE"

.



0


source







All Articles