Bug #73245 [Com]: session_start() doesn't start the session if headers have been sent

[email protected] ("daarthv at yahoo dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=73245&edit=1

 ID:                 73245
 Comment by:         daarthv at yahoo dot com
 Reported by:        php at duncanc dot co dot uk
 Summary:            session_start() doesn't start the session if headers
                     have been sent
 Status:             Wont fix
 Type:               Bug
 Package:            Session related
 Operating System:   Linux
 PHP Version:        7.1.0RC3
 Assigned To:        yohgaki
 Block user comment: N
 Private report:     N

 New Comment:

In my case session_set_cookie_params() causes problem, if i set domain, secure or httponly session is not set and cookie not sent, but if i leave only lifetime and path works ok. Any ideas how to fix it?


Previous Comments:
------------------------------------------------------------------------
[2016-10-13 22:56:54] [email protected]

@nikic 
Done. Thanks.

------------------------------------------------------------------------
[2016-10-11 16:26:46] [email protected]

@yasuo: As noted on the linked PR, it would be good to add an UPGRADING note about this.

------------------------------------------------------------------------
[2016-10-06 08:07:04] [email protected]

Not initializing $_SESSION by 2nd session_start() is not a bug actually, but it should fail to initialize $_SESSION always when session_start() cannot be started. This is the objective for the bug fix commit mentioned.

So real bug here is session module initializes $_SESSION even if it failed to start when there is no output before 1st session_start().

This report's bug won't be fixed. I re-opened bug #71038.

------------------------------------------------------------------------
[2016-10-06 08:05:58] [email protected]

Related To: Bug #71038

------------------------------------------------------------------------
[2016-10-05 15:02:37] [email protected]

Indeed, it appears to break only if there is already some output
before the first session_start(). Try:

    <?php
    echo "start\n";
    session_start();
    $_SESSION['blah'] = 'foo';
    var_dump($_SESSION);
    session_write_close();
    
    session_start();
    var_dump($_SESSION);

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=73245


--
Edit this bug report at https://bugs.php.net/bug.php?id=73245&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.