Getting ini_set(): Session error suddenly, other pages fine
- caught-in-a-nette
- Member | 12
At the start of each day (that I work on this project) I review the pages and figure out what changes need to be applied. And today was no different. I noted that many new forms were needed – so that's what I concentrated on.
Suddenly (during lunch break) I again reviewed the web pages. I was startled to find the main (first/home) page was instead showing an error, via Tracey.
Error is “ini_set(): Session ini settings cannot be changed after headers have already been sent”.
I cannot be certain what caused the error. Something else must be causing this. I definitely have not used sessions or any ini setting in this project.
My first impression was this is a header issue and probably affects the whole site. However to my amazement, all other pages worked and displayed properly.
Is there a simple fix? I am using a few libraries (from Contributte) but they must be well tested. Since this morning I added about a dozen pages and the project is now quite large.
I hope there's an easy fix for this.
- caught-in-a-nette
- Member | 12
Hi
To add:
screenshot – https://www.imgpaste.net/image/STzAY7
This happened twice, so far. I manually copied over from a backup and the site
looked good. Then again when I visited the site from ma iPad the same error
appeared. (Perhaps this has something to do with using another computer.
I suspect a session variable was used to save a value then on the other
computer it tried to get that value, but the session doesn't exist. Maybe it is
stored in the temp directory…)
Other pages show fine. I found that when I commented-out the
Contributte-Datagrid control lines it displayed fine. So it seems most likely
that library is causing this situation.
- savalo
- Member | 12
Hi, trying to solve same problem…
ini_set("session.$key", (string) $value);
in
nette/http/src/Http/Session.php:467
halts on parameters:
$option 'session.use_strict_mode'
$value '1'
Then I try to go forward via “skip error” in BSOD and got another error:
Nette\InvalidStateException
Session cannot be started after headers have already been sent
It looks that sessions are enabled, but none exists. When i dumped
getSession() only difference is that started
is
false
.
In some presenters starts session with started:true
correctly, but
some presenters have this strange behaviour.
- nightfish
- Member | 516
@savalo The reason for this error message is that the session is started too late, after the page already sent something to the output (apart from HTTP headers).
You may try to use Tracy's OutputDebugger (see example) to pinpoint where the output occurs.
The source of the problem could sometimes be deduced from the call stack in the BSOD, which you unfortunately did not provide.