Bug #76724 [Ver->Nab]: Unable to start session when using PHP CGI
| From: | cmb@php.net | Date: | Wed, 07 Jul 2021 13:58:20 +0000 |
| Subject: | Bug #76724 [Ver->Nab]: Unable to start session when using PHP CGI | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-234875@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
Updated by: cmb@php.net
Reported by: geral at braldesign dot com
Summary: Unable to start session when using PHP CGI
-Status: Verified
+Status: Not a bug
Type: Bug
Package: Session related
Operating System: CLOUDLINUX 6.10 standard
PHP Version: 7.2.8
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Time flies â¦
It's probably best to leave it as is, and to close this ticket as
not a bug:
> Either you are using php-cli and this bug is irrelevant, or you
> are using php-cgi and you should not be.
Previous Comments:
------------------------------------------------------------------------
[2018-08-09 11:34:10] cmb@php.net
In the olden days there was no CLI SAPI. Instead the CGI
executable could be used, and -q (which is --no-headers) served to
make it more useful for the command line. For better
compatibility with the CLI SAPI, we might consider to âfixâ it[1].
OTOH, perhaps we should rid the -q option of the CGI SAPI
altogether?
Anyhow, the following workaround might be sufficient in this case:
php -q -d session.use_cookies=0 -d session.cache_limiter="" <file>
[1] <https://github.com/php/php-src/blob/php-7.3.0beta1/sapi/cgi/cgi_main.c#L2420>
------------------------------------------------------------------------
[2018-08-09 10:01:07] geral at braldesign dot com
The /usr/bin/php is the cgi version :
# /usr/bin/php -v
PHP 7.2.8 (cgi-fcgi) (built: Jul 19 2018 09:57:11)
Apparently this is setup like this as deployed by CloudLinux service, should I contact them about
this?
------------------------------------------------------------------------
[2018-08-09 09:56:25] spam2 at rhsoft dot net
if you provider is using cgi-fcgi instead of /usr/bin/php for cronjobs he is a fool becaus ethat
breaks the usual way such code looks like
if(PHP_SAPI !== 'cli')
{
session_start();
}
------------------------------------------------------------------------
[2018-08-09 09:54:18] geral at braldesign dot com
I was retesting everything, so my server provider uses cgi-fcgi to execute cronjobs, to test this I
just echo php_sapi_name() on an empty script executed by cronjob.
I'm only using sessions because the backoffice uses it, i'm only using it as global
variables.
------------------------------------------------------------------------
[2018-08-09 09:30:29] requinix@php.net
php-cli should be used for cronjobs, yes, but this bug report is about php-cgi. They are not the
same.
Either you are using php-cli and this bug is irrelevant, or you are using php-cgi and you should not
be.
And you know sessions don't really work from the command line, right? You would have to force a
particular session ID, new or existing, for sessions to work across multiple runs.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=76724
--
Edit this bug report at https://bugs.php.net/bug.php?id=76724&edit=1