Hello!
Is there a way to store objects that consist of some other agregated objects as session variables (ie.
class menu_item {
....}
class menu {
var $caption // this is a string
var $items; // array of menu_item instances
// or references to objects
function add_item(&$item){..}
...}
) and access their agregated objects.
When I store $menu1 as session variable I can't access its member objects ($menu1->items[1]), but $menu1->caption.

    Yes. I've thought about serializing, but I suspect handling session already uses serializing to keep objects or whatever. It doesn't work out for me. Maybe because of bugs or features in the function serialize(). This is a simple example:
    <body>
    <? class ctest {
    var $items;
    function add_item($item){ $this->items[] = $item; }
    }
    class ctest2 {
    var $name;
    function null(){}
    }

    $test = new ctest;
    $test2 = new ctest2; $test2->name = "WOW";
    $test->add_item($test2);
    echo serialize($test) . "<br>";
    $test->items[0]->null(); // SIC!
    //After calling null function the agregated
    //object is empty!!!
    echo serialize($test);
    ?>
    </body>

    As result I see
    O:5:"ctest":1:{s:5:"items";a:1:{i:0;O:6:"ctest2":1:{s:4:"name";s:3:"WOW";}}}
    O:5:"ctest":1:{s:5:"items";a:1:{}}

    version is 4.0.3pl1
    Do you see the same?

    Moreover, it doesn't work for referenced agregated objects.

      Write a Reply...