Hi all Using PHP5, I am trying to save some properties of an object when it is destroyed in its destructor, __destruct(). However, I have found that the session variable is NOT stored unless I explicitly destroy the object using unset(). If I leave php to finish executing the script and automatically destroy the object, the destructor IS called, however, the session variables are NOT saved. A quick code example for clarity:
----- class StateMachine { public $stateVariable; function __destruct() { $_SESSION['state'] = $this->stateVariable; } } $sm = new StateMachine(); if (isset($_SESSION['state'])) { $sm->stateVariable = $_SESSION['state']; } else { $sm->stateVariable = 'foobar'; } ---- (please ignore the obvious bad coding standard of making that var public and accessing it, this is for simplicity of the example). Unless I do an unset($sm); at the end of a script like this, the $_SESSION array will never contain the state=>foobar key/value. Can anyone offer some insight into this? Thanks! Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php