#27555 [Com]: Unable to modify $_SESSION from __destruct()
| From: | fschaper at intux dot org | Date: | Tue, 01 Jun 2004 15:22:23 +0000 |
| Subject: | #27555 [Com]: Unable to modify $_SESSION from __destruct() | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969361124@lists.php.net to get a copy of this message | ||
ID: 27555
Comment by: fschaper at intux dot org
Reported By: jaanus at heeringson dot com
Status: Open
Bug Type: Documentation problem
Operating System: Linux 2.4.24
PHP Version: 5CVS-2004-03-10 (dev)
New Comment:
Why not to call the destructors before the modules are shut down? I
wrote a short patch for this and it works out fine (That does not mean
however that it does not break something ,) ).
http://www.intux.org/download/patches/patch_php_cvs_01_06_04.rar
Previous Comments:
------------------------------------------------------------------------
[2004-03-11 04:34:16] derick@php.net
It's still not documented, leave it as an open doc bug.
------------------------------------------------------------------------
[2004-03-11 04:28:32] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The destructor is executed too late in the shutdown sequence. If you
want a destructor to modify some $_SESSION
then you need to manually refcount and free all references using
unset() before the script terminates.
------------------------------------------------------------------------
[2004-03-11 03:16:29] derick@php.net
Destructors are run (when not unset-ing yourself) after the session
module finalizes the session so everything done in constructors has no
effect. I agree it's not optimal behavior, but I don't think we need to
classify it as a bug. It is not documented though so I'm making this a
documentation problem.
------------------------------------------------------------------------
[2004-03-11 02:35:15] jaanus at heeringson dot com
Yes, but that is not the issue here, is it? What this bug is about is
the unability to add session variables from __destruct(). Obviously you
have to reload the page to se the effect on the real session. The
[destructor] => Yes will NEVER appear in $_SESSION.
------------------------------------------------------------------------
[2004-03-10 19:50:59] sniper@php.net
If you put something like "echo 'this happens now';" line in the
__destruct() call you will see that it's executed AFTER your print_r()
line. This is correct behaviour.
------------------------------------------------------------------------
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
http://bugs.php.net/27555
--
Edit this bug report at http://bugs.php.net/?id=27555&edit=1