RE: [PHP-GENERAL] Classes, objects, and a huge problem!

From: Date: Mon, 12 Jun 2000 06:02:57 +0000
Subject: RE: [PHP-GENERAL] Classes, objects, and a huge problem!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-1592@lists.php.net to get a copy of this message
Make sure that you are not confusing a class and an instance. I believe the session saves the instance data across pages, but I think it is up to you to make sure the class is there on each page where instances of the class are used. > -----Original Message----- > From: Szii [mailto:szii@earthlink.net] > Sent: Sunday, June 11, 2000 9:11 PM > To: php-general@lists.php.net > Subject: [PHP-GENERAL] Classes, objects, and a huge problem! > > > 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 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#1592) next »