Doc #55849 [Opn->Bgs]: session_start() return value mismatch to docs

From: Date: Sat, 08 Oct 2011 21:08:36 +0000
Subject: Doc #55849 [Opn->Bgs]: session_start() return value mismatch to docs
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-7300@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55849&edit=1 ID: 55849 Updated by: frozenfire@php.net Reported by: tklingeberg at lastflood dot net Summary: session_start() return value mismatch to docs -Status: Open +Status: Bogus Type: Documentation Problem Package: Session related Operating System: Linux PHP Version: 5.3.8 Block user comment: N Private report: N New Comment: I believe this is intended behaviour, and the documentation is correct. session_start() returns true if a session is started. It returns false if a session fails to start. What this means is that if a session is already started, then it has succeeded in ensuring that a session is started, because one already did. To return false when the function is called, because a session is already started, would likely break code that uses session_start() instead of the upcoming session_status() function to check whether a session is available. The documentation is correct in saying that it only returns false if the session *fails* to start, in the sense that no session will be available. I've verified this is the behaviour in the 5.3.8 release, through the source code. Previous Comments: ------------------------------------------------------------------------ [2011-10-05 03:05:56] tklingenberg at lastflood dot net Related: https://bugs.php.net/bug.php?id=52982 (PHP 5.4 new session_status() function) ------------------------------------------------------------------------ [2011-10-04 23:12:54] tklingeberg at lastflood dot net Description: ------------ In http://www.php.net/manual/en/function.session-start.php it's written that the return value of the function: Changelog Version Description 5.3.0 If a session fails to start, then FALSE is returned. Previously TRUE was returned. This information is wrong. With PHP 5.3.8 on my Fedora box in CLI mode, the function returns true, even if called a second time. It gives a notice that it does not work, but it returns TRUE. Related: * https://bugs.php.net/bug.php?id=2126 Test script: --------------- <?php session_start(); $r = session_start(); echo (int) $r; ?> Expected result: ---------------- 0 Actual result: -------------- 1 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=55849&edit=1

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