ERROR msg: session_commit(): Cannot call session save handler in a recursive manner

2,121 views
Skip to first unread message

Richard Catto

unread,
Aug 31, 2017, 11:49:19 AM8/31/17
to Fat-Free Framework
I get this error on accessing my site:

session_commit(): Cannot call session save handler in a recursive manner

if I refresh the page, it goes away.

The error traces to this code in a class method:

$this->f3->set('SESSION.email',$email);

I start a session in my index.php like this:

$s = new \DB\SQL\Session($dbPDO);

this gets called before I attempt to set a session variable.

Any idea what is happening and how to fix this?

ved

unread,
Aug 31, 2017, 12:05:29 PM8/31/17
to Fat-Free Framework
Was it working before?

Are you using php >7.1?

This issue may be related.

Richard Catto

unread,
Aug 31, 2017, 12:48:32 PM8/31/17
to Fat-Free Framework
I didn't use session variables before. using php v7.1.8

ved

unread,
Aug 31, 2017, 1:00:30 PM8/31/17
to Fat-Free Framework
Yeah it's probably that issue. F3's session handlers seem to be affected by that issue.

If you can, please try your app without using any of F3's session handlers (so, using only plain php sessions) and see if the issue goes away.

Richard Catto

unread,
Aug 31, 2017, 1:15:44 PM8/31/17
to Fat-Free Framework
Okay, I commented out:

// $s = new \DB\SQL\Session($dbPDO);

and the error isn't coming up.

I'll conduct more tests, see if I can narrow it down.

Richard Catto

unread,
Aug 31, 2017, 6:33:43 PM8/31/17
to Fat-Free Framework
File: lib/db/sql/session.php

function read($id) {
$this->load(['session_id=?',$this->sid=$id]);
if ($this->dry()) return '';
        /* *** commented out ***
if ($this->get('ip')!=$this->_ip || $this->get('agent')!=$this->_agent) {
$fw=\Base::instance();
if (!isset($this->onsuspect) || $fw->call($this->onsuspect,[$this,$id])===FALSE) {
//NB: `session_destroy` can't be called at that stage (`session_start` not completed)
$this->destroy($id);
$this->close();
$fw->clear('COOKIE.'.session_name());
$fw->error(403);
}
}
        *** end commented out *** */
return $this->get('data');
}

the code that checks if the IP or AGENT has changed destroys the current sesssion, removes the record from the db, and stops execution with a 403.

If you ignore IP / AGENT changes, by commenting out the code which checks this, then the problem does not arise.

this was done just to isolate where in the code the issue occurs.

I think the correct way to fix this would be to destroy the session, and then create a new one, without stopping execution.


On Thursday, August 31, 2017 at 7:00:30 PM UTC+2, ved wrote:
Reply all
Reply to author
Forward
0 new messages