Classes and Sessions

From: Date: Thu, 01 Jun 2000 17:12:16 +0000
Subject: Classes and Sessions
Groups: php.general 
Request: Send a blank email to php-general+get-848@lists.php.net to get a copy of this message
I've noticed an oddity with classes and sessions. --snip session_start(); if (!isset($session) { $session_object = new class_session_object; session_register("session_object"); } $session_object->method(); --end snip If you include the whole "if (!isset()) " block at the top of every page then this works. However, if you transfer from this page to another page that doesn't have it, and then come back to this page you'll get "undefined function" errors. (even with the block) So, my next step is to modify the block, and put an else clause on it with a debug output. Yes, the variable's already set in the session (as it should be) but you can't call methods off of it! Now, my understanding is that this class should just hang out indefinitely until it's explicity removed. It looks like PHP deems $session_object as "set" when it's really not, or the function table for the class isn't being saved correctly. The "workaround" is to shut down your browser, put the "if (isset())" at the top of each file everywhere. *blink* If you don't, and your user hits another non-header'd page and comes back your pages will tweak on the method calls. I've not tried it with outside pages...perhaps tonight. There's something afoot with classes and sessions.... =) -Szii

« previous php.general (#848) next »