Bug #76724 [Com]: Unable to start session when using PHP CGI
| From: | spam2 at rhsoft dot net | Date: | Thu, 09 Aug 2018 09:28:27 +0000 |
| Subject: | Bug #76724 [Com]: Unable to start session when using PHP CGI | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-216686@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76724&edit=1
ID: 76724
Comment by: spam2 at rhsoft dot net
Reported by: geral at braldesign dot com
Summary: Unable to start session when using PHP CGI
Status: Verified
Type: Bug
Package: Session related
Operating System: CLOUDLINUX 6.10 standard
PHP Version: 7.2.8
Block user comment: N
Private report: N
New Comment:
a proper software runtime skips session_start() when not running within a webserver environment,
these are a few lines of PHP code and be it only to prevent spit session files to disk for no gain
Previous Comments:
------------------------------------------------------------------------
[2018-08-09 09:24:14] geral at braldesign dot com
I'm using the php-cli only because it is the default used by cron jobs and i'm using
session on it just because the script uses session to store data for the execution.
If this behavior is intended I can only work around it.
Thanks for the explanation.
------------------------------------------------------------------------
[2018-08-09 09:19:05] requinix@php.net
Well, without knowing what you're doing or why, I would suggest using the regular PHP binary
instead of php-cgi.
------------------------------------------------------------------------
[2018-08-09 09:17:49] geral at braldesign dot com
Then, there is no way to use a session with a quiet script? thanks.
------------------------------------------------------------------------
[2018-08-09 09:14:31] requinix@php.net
-q deliberately makes the scripting engine think that headers have been sent, but it's been
that way for so long that I can't say exactly why it does so. I can only assume there is/was a
good reason.
------------------------------------------------------------------------
[2018-08-09 07:21:45] geral at braldesign dot com
Description:
------------
When executing the script with PHP CGI 7.2 and the flag "-q" it will generate one warning.
When not using thr flag it works as expected.
Test script:
---------------
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
Expected result:
----------------
no warning nor errors.
Actual result:
--------------
<b>Warning</b>: session_start(): Cannot start session when headers already sent in ...
on line <b>7</b>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76724&edit=1