Bug #74514 [Ana->Ver]: 5 session functions incorrectly warn when calling in read-only/getter mode

From: Date: Fri, 30 Jun 2017 15:37:20 +0000
Subject: Bug #74514 [Ana->Ver]: 5 session functions incorrectly warn when calling in read-only/getter mode
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209743@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:         yohgaki@php.net
 Reported by:        spam2 at rhsoft dot net
 Summary:            5 session functions incorrectly warn when calling in
                     read-only/getter mode
-Status:             Analyzed
+Status:             Verified
 Type:               Bug
 Package:            Session related
 Operating System:   Linux
 PHP Version:        7.2.0alpha2
 Assigned To:        yohgaki
 Block user comment: N
 Private report:     N

 New Comment:

It seems current master's session_name() is changed to send cookie even when it shouldn't.


[yohgaki@dev PHP-master]$ ./sapi/cli/php -r
'var_dump($n=session_name("foo"));var_dump(session_name());'
string(9) "PHPSESSID"

Warning: session_name(): Cannot change session name when headers already sent in Command line code
on line 1
bool(false)
[yohgaki@dev PHP-master]$ php -v
PHP 7.0.20 (cli) (built: Jun  7 2017 04:59:25) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.20, Copyright (c) 1999-2017, by Zend Technologies
[yohgaki@dev PHP-master]$ php -r
'var_dump($n=session_name("foo"));var_dump(session_name());'
string(9) "PHPSESSID"
string(3) "foo"


Previous Comments:
------------------------------------------------------------------------
[2017-06-23 23:59:34] requinix@php.net

Related To: Bug #74809

------------------------------------------------------------------------
[2017-05-07 14:55:31] requinix@php.net

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.

------------------------------------------------------------------------
[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?

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


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 (#209743) next »