ID:               27555
 User updated by:  jaanus at heeringson dot com
 Reported By:      jaanus at heeringson dot com
-Status:           Bogus
+Status:           Open
 Bug Type:         Session related
 Operating System: Linux 2.4.24
 PHP Version:      5CVS-2004-03-10 (dev)
 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[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

Reply via email to