Classes, objects, and a huge problem!

From: Date: Mon, 12 Jun 2000 04:11:26 +0000
Subject: Classes, objects, and a huge problem!
Groups: php.general 
Request: Send a blank email to php-general+get-1589@lists.php.net to get a copy of this message
Okay, after MUCH testing here's what's up with registered values and sessions... If you start a session and register a CLASS you're fine. Register a second class, and you're fine. UNTIL YOU SWITCH PAGES. At that point the class is still registered, and defined to the session but it acts like the vtable's whacked. You can access member vars normally, it's just the functions that get lost. ie, isset() and session_is_registered() BOTH pass true on the class variable but when attempt a call off of that class then your class with yell about "undefined function." I posted this before, but was 1/2 unsure about the details. I'm posting it again in the hopes of getting it fixed. I -am- registering multiple classes with my session. If you include the following at the top of EVERY file for EVERY CLASS you're okay across pages. if (!isset($my_class)) { $my_class = new class_MyClass; session_register("my_class"); } if (!isset($my_class2)) { $my_class2 = new class_MyClass2; session_register("my_class2"); } etc... Someone mentioned changing the order of my require() calls to BEFORE the session_start() call, but it didn't help. In summary, if someone hits your site and has a session with multiple registered classes and then leaves - only to come back within the same session then your classes are garbage. "Leaves" in this case is either leaving the page to a non-registering page or leaving your site entirely (which is still a non-registering page.) Ex: Page1 starts a session, and registers a 3 classes. (class1,class2,class3) Go to page 2. Go back to page1 Attempt a function call off of Class1,2,3. If you look at the server-side session file it'll show you all 3 classes, and you can do everything with those Classes EXCEP call methods off of them. Thanks! -Szii

« previous php.general (#1589) next »