#45270 [Opn->Fbk]: session_start() incorrectly tries to send a cookie

From: Date: Tue, 08 Jul 2008 13:30:32 +0000
Subject: #45270 [Opn->Fbk]: session_start() incorrectly tries to send a cookie
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-126378@lists.php.net to get a copy of this message
ID: 45270 Updated by: jani@php.net Reported By: vesselin dot atanasov at gmail dot com -Status: Open +Status: Feedback Bug Type: Session related Operating System: Fedora Core 8 PHP Version: 5.2.6 New Comment: Why would you stop and start a session in same request? It's by design like this.. Previous Comments: ------------------------------------------------------------------------ [2008-06-14 14:05:09] vesselin dot atanasov at gmail dot com Description: ------------ session_start() incorrectly tries to send a cookie even when it has already been sent. This causes problems with sessions that are closed with session_write_close() some output has been sent and then the session is re-opened with session_start() The second time when session_start() is called it should avoid sending the cookie and cache headers, since they have already been sent by the first call to session_start(). It seems that the second time session_start() tries to send the same cookie value as the first time, so it should be possible to avoid sending that cookie a second time. Reproduce code: --------------- <?php session_start (); session_write_close (); print ("Test"); session_start (); ?> Expected result: ---------------- No output at all. Actual result: -------------- Test Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/medical/htdocs/try.php:4) in /var/medical/htdocs/try.php on line 5 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/medical/htdocs/try.php:4) in /var/medical/htdocs/try.php on line 5 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45270&edit=1

« previous php.bugs (#126378) next »