Welcome Guest, Not a member yet? Register   Sign In
Problem with session handling
#1

Hi
I've just upgraded to version 4.4.8
I have a session service of my own which I am using, however this now seems to clash with the codeigniter session service.
I get the following
ErrorException

ini_set(): A session is active. You cannot change the session module's ini settings at this time
SYSTEMPATH/Session/Handlers/FileHandler.php at line 72
Code:
65
66    public function __construct(SessionConfig $config, string $ipAddress)
67    {
68        parent::__construct($config, $ipAddress);
69
70        if (! empty($this->savePath)) {
71            $this->savePath = rtrim($this->savePath, '/\\');
72            ini_set('session.save_path', $this->savePath);
73        } else {
74            $sessionPath = rtrim(ini_get('session.save_path'), '/\\');
75
76            if ($sessionPath === '') {
77                $sessionPath = WRITEPATH . 'session';
78            }
79
I am not using the Codeigniter session service, it appears to being initialized by the method storePreviousURL in Codeigniter.php, the condition is purely


Code:
        if (isset($_SESSION)) {
            session()->set('_ci_previous_url', URI::createURIString(
                $uri->getScheme(),
                $uri->getAuthority(),
                $uri->getPath(),
                $uri->getQuery(),
                $uri->getFragment()
            ));
        }
Does anyone know of a way of fixing this easily?

Jules
Reply
#2

1. Replace Session class with your Session class
2. Replace CodeIgniter class, and remove the if statement
See https://codeigniter4.github.io/CodeIgnit...re-classes
Reply
#3

(This post was last modified: 04-26-2024, 04:41 AM by Julesb.)

Hi Kenjis

Thanks for the ideas

Had a long look at various solutions, replacing the session class was just a pain as it did not fix the problem and  caused others.

Ended editing Codeigniter.php

Line 1069 now reads
Code:
        if (isset($_SESSION)) {
            $_SESSION['_ci_previous_url'] = URI::createURIString(
                $uri->getScheme(),
                $uri->getAuthority(),
                $uri->getPath(),
                $uri->getQuery(),
                $uri->getFragment()
            );
        }


Basically as its a string returned by URI::createURIString you don't really need the complex session handling stuff, not an optimum solution though.

Managed to get my brain in gear, replaced the CodeIgniter class with my own.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB