Hi, I have problem accessing object stored in session with PHP.
SUMMARY ************* The doc says I must put the object definition (require_once("MyObject.php");) before the session starts (with a session_start() ). If I do that - OK I can get my object from session - OK my object is "casted" in MyObject object type SAMPLE / the problem *************************** But my code is organised in several sub-scripts (Object oriented, simplified dor the explanation) : The request.php is performed through part_1.php and part_2.php with 2 include calls - request.php starts the session and do some initialization stuff. - include("part_1.php") do some business things here call some object and try to read them from session - include("part_2.php") do some other logic here end the response sent to the browser As you already understand, the session starts BEFORE PHP enters part_1.php and it is too late in part_1.php to put the object definition with the require_once. I cannot re organise my php files, since part_1.php is as its own business logic and I want to use it elsewhere. The object which is thus restored from session is not "finished". If I do a var_dump on it I have something like : object(__PHP_Incomplete_Class)(3) { ["__PHP_Incomplete_Class_Name"]=> string(6) "classe" ["n"]=> int(1) ["sub"]=> object(__PHP_Incomplete_Class)(2) { ["__PHP_Incomplete_Class_Name"]=> string(9) "subclasse" ["i"]=> int(1) } } instead of object(classe)(2) { ["n"]=> int(1) ["sub"]=> object(subclasse)(1) { ["i"]=> int(1) } } It looks like there is a special intermediate object of type __PHP_Incomplete_Class. If another object is an attribut of the session stored object, it is also incomplete. If I try to call some methods on it it throws an error saying the object is incomplete and I cannot call methods or attributs on it. TEMPORARY SOLUTION ****************************** What I do actually is making a kind of copy of this object trough introspection and explicit casting : $myObject =& convert("MyObjet", $IncompleteClassInstance) ; But : - this is not very convenient - the MyObject must support a constructor with no arguments since the process of conversion is : * create a new instance of MyObject with no arguments (new MyObject( ); ) * copy the attributes of the incomplete instance in this new Instance recurse if an attribute is itself another object * return the new instance QUESTIONS *************** Any idea about standard object casting in PHP ? The process between class def and session starting if my session is auto started (change in my php.ini) results in an error. Thus I can affirm there is a bug in the session handling of PHP :"It is not possible to store object in session if we use auto started sessions" Alex -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]