Bug->Doc #75946 [Opn]: session_start() fails after fastcgi_finish_request() (FPM)

From: Date: Sat, 10 Feb 2018 15:33:54 +0000
Subject: Bug->Doc #75946 [Opn]: session_start() fails after fastcgi_finish_request() (FPM)
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15420@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75946&edit=1 ID: 75946 User updated by: rafal dot janiczek at gmail dot com Reported by: rafal dot janiczek at gmail dot com Summary: session_start() fails after fastcgi_finish_request() (FPM) Status: Open -Type: Bug +Type: Documentation Problem Package: Session related Operating System: Linux PHP Version: 7.1.14 Block user comment: N Private report: N New Comment: 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(). Previous Comments: ------------------------------------------------------------------------ [2018-02-10 13:38:30] 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 11:10:07] 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 http://php.net/manual/en/function.session-start.php ? There is nothing about that change in >7.1 series. https://3v4l.org/A06Gr ------------------------------------------------------------------------ [2018-02-10 09:57:16] 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 09:11:57] rafal dot janiczek at gmail dot com Description: ------------ Not affected: php 7.0.x Affected: php7.1.x (tested .14) and php7.2.x (tested .2) Test script: --------------- <?php session_start(); echo session_id()."\n"; $_SESSION['test'] = 1; echo "stop session\n"; session_write_close(); fastcgi_finish_request(); session_start(); $_SESSION['test'] = 2; session_write_close(); $status = session_start(); if ($status) file_put_contents("sesstest.log", date("Y-m-d")." OK ".$_SESSION['test']." ".session_id()); else 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75946&edit=1

« previous php.doc.bugs (#15420) next »