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

From: Date: Sat, 10 Feb 2018 11:10:08 +0000
Subject: Bug #75946 [Opn]: session_start() fails after fastcgi_finish_request() (FPM)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213905@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 Package: Session related Operating System: Linux PHP Version: 7.1.14 Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [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.bugs (#213905) next »