ID: 27555 Updated by: [EMAIL PROTECTED] Reported By: jaanus at heeringson dot com -Status: Bogus +Status: Open Bug Type: Documentation problem Operating System: Linux 2.4.24 PHP Version: 5CVS-2004-03-10 (dev) New Comment:
It's still not documented, leave it as an open doc bug. Previous Comments: ------------------------------------------------------------------------ [2004-03-11 04:28:32] [EMAIL PROTECTED] 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] [EMAIL PROTECTED] 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] [EMAIL PROTECTED] 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. ------------------------------------------------------------------------ [2004-03-10 18:42:06] jaanus at heeringson dot com Description: ------------ Unable to add session variables from the __destruct() handler in a class. The $_SESSION variable can be accessed and viewed in the __destruct() handler though. Reproduce code: --------------- <pre> <?php session_start(); class test{ public function __destruct(){ $_SESSION['destructor']='Yes'; } } $class=new test(); if(empty($_SESSION['working'])) { $_SESSION['working']='Yes'; print("New session?\n"); } print_r($_SESSION); ?> </pre> Expected result: ---------------- Array ( [destructor] => Yes [working] => Yes ) Actual result: -------------- Array ( [working] => Yes ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27555&edit=1
