Bug #74514 [NoF->Ana]: PHP Warning: session_name(): Cannot change session name when headers already

From: Date: Sun, 07 May 2017 14:55:33 +0000
Subject: Bug #74514 [NoF->Ana]: PHP Warning: session_name(): Cannot change session name when headers already
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208987@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74514&edit=1

 ID:                 74514
 Updated by:         requinix@php.net
 Reported by:        spam2 at rhsoft dot net
 Summary:             PHP Warning:  session_name(): Cannot change session
                     name when headers already
-Status:             No Feedback
+Status:             Analyzed
 Type:               Bug
 Package:            Session related
 Operating System:   Linux
 PHP Version:        master-Git-2017-04-29 (Git)
-Assigned To:        
+Assigned To:        yohgaki
 Block user comment: N
 Private report:     N

 New Comment:

Affects master only.
<?php echo " "; session_name();

https://github.com/php/php-src/commit/7f196e321fa464075248eced7d0d2c046b686b24

session_name, session_module_name, session_save_path, session_cache_limiter, and
session_cache_expire could all use changes like

- 	if (SG(headers_sent)) {
+	if (name && SG(headers_sent)) {

(which is used now but inconsistently) to allow read-only calls. Also, session_cache_expire has a
RETURN_LONG for an active session where the other functions will RETURN_FALSE.


Previous Comments:
------------------------------------------------------------------------
[2017-05-07 09:06:09] spam2 at rhsoft dot net

WTF - did you even read the error message from the initial report and the fact calling the function
without parameters is not supposed to write any headers or start a session - i just want the current
setting to parse out the session cookie from response headers on that same machine 

However, do what you want, as I said for my use case ini_get is a workaround while it could be
prohibited on production machines and when session_name changed the name it is probably no longer
the same value

------------------------------------------------------------------------
[2017-05-07 04:22:37] php-bugs at lists dot php dot net

No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.

------------------------------------------------------------------------
[2017-04-29 23:05:13] spam2 at rhsoft dot net

http://php.net/manual/en/function.session-name.php

> session_name() returns the name of the current session. If name is given, 
> session_name() will update the session name and return the old session name
_____________

$session_name = session_name();

do you see a name given here?

------------------------------------------------------------------------
[2017-04-29 23:01:28] spam2 at rhsoft dot net

just run a CLI script with no session started - the line from te origin report is one of many
thousands and it's intention is to work environment independet and get/send the correct cookie
for thousands of curl calls

i will rewrite the code now to "ini_get('session.name'); but that don't change
the fact that there is some BC change

------------------------------------------------------------------------
[2017-04-29 22:51:57] daverandom@php.net

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.



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


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=74514


--
Edit this bug report at https://bugs.php.net/bug.php?id=74514&edit=1


Thread (9 messages)

« previous php.bugs (#208987) next »