ID:               29032
 Updated by:       php-bugs@lists.php.net
 Reported By:      antonr at game dot permonline dot ru
-Status:           Feedback
+Status:           No Feedback
 Bug Type:         Session related
 Operating System: Irrelevant
 PHP Version:      5CVS-2004-07-06 (dev)
 New Comment:

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".


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

[2005-03-06 20:35:59] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



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

[2004-12-06 05:34:29] anthony at ectrolinux dot com

For reference, this bug appears to be synonymous to bug #30578, with
the same cause but a different effect.

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

[2004-10-26 02:40:15] auroraeosrose at hotmail dot com

Modifying $_SESSION in the destructor ONLY works if you call
unset($object) before the end of your script, however this is a pain in
the rear - and if you have references to that object elsewhere it
doesn't work properly.

There is a workaround... You CAN use register_shutdown_function in the
constructor of your class

      public function __construct()
        { 
register_shutdown_function(array($this, '__destruct');
        } 

and then the destruct is called early enough that you can modify
$_SESSION. But this defeats the whole purpose of a destructor - I could
do that in every class if php5 didn't support destructors (in fact I did
in php4) but I thought the point was to eliminate messy workarounds. 
Now why in the world the sessions are closed in between when shutdown
functions and destructors are called is beyond me.

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

[2004-07-06 16:58:15] antonr at game dot permonline dot ru

Description:
------------
Session are closed before all object destructors executed. It seems to
be wrong, cause objects desctructors may save information in opened
session.


Reproduce code:
---------------
<?php

  class MySession
    { public $number; 
      public function __construct()
        { session_start();
          $this->number = @$_SESSION["number"];
        }
      public function Process()
        { $this->number++;
        }
      public function __destruct()
        { $_SESSION["number"] = $this->number;
          session_write_close();
        }
    }

  $ss = new MySession();
  $ss->Process();
  echo $ss->number;

?>


Expected result:
----------------
With every page reloading number in the page must increase by 1.

Actual result:
--------------
Everytime number is equal 1.


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


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

Reply via email to