|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75946 session_start() fails after fastcgi_finish_request() (FPM)
Submitted: 2018-02-10 09:11 UTC Modified: 2018-02-11 13:36 UTC
From: rafal dot janiczek at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Session related
PHP Version: 7.1.14 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: rafal dot janiczek at gmail dot com
New email:
PHP Version: OS:


 [2018-02-10 09:11 UTC] rafal dot janiczek at gmail dot com
Not affected: php 7.0.x 

Affected: php7.1.x (tested .14) and php7.2.x (tested .2)

Test script:


echo session_id()."\n";
$_SESSION['test'] = 1;

echo "stop session\n";


$_SESSION['test'] = 2;

$status = session_start();

if ($status)
    file_put_contents("sesstest.log", date("Y-m-d")." OK ".$_SESSION['test']." ".session_id());
    file_put_contents("sesstest.log", date("Y-m-d")." ERR ".$_SESSION['test']." ".session_id());

Expected result:
string "OK 2" in sesstest.log

Actual result:
string "ERR 1" in sesstest.log


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-10 09:57 UTC] spam2 at rhsoft dot net
this is not a bug! you can't start a session after data was sent to the client which happens with fastcgi_finish_request() as "This function flushes all response data to the client and finishes the request. This allows for time consuming tasks to be performed without leaving the connection to the client open" clearly states

why do you believe that this piece of code ever did what you think?

the only difference is that PHP now tells you that your code is and was always broken and thinking abotu what session_start() does - sending a HTTP header - that becomes obvious
 [2018-02-10 11:10 UTC] rafal dot janiczek at gmail dot com
You'are right, it's bad code, but this piece of code was working since php-5.5.21(first time) and checking on 3v4l it was working since 4.3.x. Of course always with warning (headers already sent), but was working. Now it's problem with php 7.1 and 7.2. For me it's bug or regression. 

Maybe it's good to inform about that on ? There is nothing about that change in >7.1 series.
 [2018-02-10 13:38 UTC] spam2 at rhsoft dot net
jesus christ when you get a warning "headers already sent" it did NOT work because the whole purpose of session_start() is send the PHPSESSID cookie to the client

again: you thought it worked but it never did and now you get the truth additional to the warning - so say thank you that a major bug was fixed and points out broken code you never realized how broken it is
 [2018-02-10 15:33 UTC] rafal dot janiczek at gmail dot com
-Type: Bug +Type: Documentation Problem
 [2018-02-10 15:33 UTC] rafal dot janiczek at gmail dot com
Ok, propoably this report is related with #71038.

But if it was major fix for sessions why there's no any info on session_start page or "PHP 7.1.0 Release Announcement" or "Backward incompatible changes"? 

Please just write it in changelog box for session_start().
 [2018-02-11 13:14 UTC]
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2018-02-11 13:14 UTC]
Indeed, even though there is an explicit mention in UPGRADING[1],
this wasn't incorporated in the changelog.

[1] <>
 [2018-02-11 13:36 UTC]
Automatic comment from SVN on behalf of cmb
Log: Fix bug #75946 (session_start() fails after fastcgi_finish_request() (FPM))
 [2018-02-11 13:36 UTC]
-Status: Verified +Status: Closed
 [2018-02-11 13:36 UTC]
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2020-02-07 06:05 UTC]
Automatic comment on behalf of cmb
Log: Fix bug #75946 (session_start() fails after fastcgi_finish_request() (FPM))
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Dec 06 21:05:51 2022 UTC