Welcome Guest, Not a member yet? Register   Sign In
CI 4.1.8 session issues
#1

Hi guys,
I have weird issue with CI4 session.

Every 2nd page reload throws ErrorException - session_start(): Failed to decode session object. Session has been destroyed

- i did upgrade to CI 4.1.8
- i use Myth:auth, but even if just refresh homepage without login
- if i login, i land in dashboard - OK, F5 and session is gone

Config/App.php

PHP Code:
public $sessionDriver 'CodeIgniter\Session\Handlers\DatabaseHandler';
public 
$sessionCookieName 'ci_session';
public 
$sessionExpiration 0;
public 
$sessionSavePath 'ci_sessions';
public 
$sessionMatchIP false;
public 
$sessionTimeToUpdate 300;
public 
$sessionRegenerateDestroy false


Created MySQL 'ci_sessions' table from userguide:

https://codeigniter4.github.io/userguide/libraries/sessions.html

Code:
CREATE TABLE IF NOT EXISTS `ci_sessions` (
    `id` varchar(128) NOT null,
    `ip_address` varchar(45) NOT null,
    `timestamp` timestamp DEFAULT CURRENT_TIMESTAMP NOT null,
    `data` blob NOT null,
    KEY `ci_sessions_timestamp` (`timestamp`)
);

ALTER TABLE ci_sessions ADD PRIMARY KEY (id);

PHP 7.4.27 php.ini
Code:
session.auto_start Off Off
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_httponly no value no value
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_samesite no value no value
session.cookie_secure 0 0
session.gc_divisor 1000 1000
session.gc_maxlifetime 1440 1440
session.gc_probability 0 0
session.lazy_write On On
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /var/lib/php/sessions /var/lib/php/sessions
session.serialize_handler php php
session.sid_bits_per_character 5 5
session.sid_length 26 26
session.upload_progress.cleanup On On
session.upload_progress.enabled On On
session.upload_progress.freq 1% 1%
session.upload_progress.min_freq 1 1
session.upload_progress.name PHP_SESSION_UPLOAD_PROGRESS PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix upload_progress_ upload_progress_
session.use_cookies 1 1
session.use_only_cookies 1 1
session.use_strict_mode 0 0
session.use_trans_sid 0 0

This session setup always has worked. 

Can anyone tell what config options i need to change? Server variables?
Maybe some hidden stuff in Myth:auth module?
What setup does work for you?
Reply
#2

3 days later...

Cause of the problem was that CI session could not be written into database.
Simply session was too big, therefore on the next reload it could not be read.

https://codeigniter.com/user_guide/libra...ler-driver

When creating a `ci_sessions` table, use `mediumblob` instead of `blob`

blob - 65,535 bytes
mediumblob - 16,777,215 bytes
Reply




Theme © iAndrew 2016 - Forum software by © MyBB