From: Doug R. <dou...@re...> - 2003-12-16 21:47:15
|
I've been playing with inc/runtime.php and 0.9.3-2 but I can't use session variables to point at a class reliably. I'd like to at least work out what is going on before hacking it to work in the always array. I need runtime.php to check for a session pointer to a class, and if it doesn't exist, to create it. It appears to work once, and then on subsequent reloads, the session pointer is still set but not pointing at the class. Trivial example: I create an inc/runtime.php which looks like: <?php require_once(PHPWS_SOURCE_DIR . 'mod/kcart/class/kcTest.php'); if (!isset($_SESSION["SES_kcart_kctest"])) { $_SESSION["SES_kcart_kctest"] = new kcTest; } if (isset($_SESSION["SES_kcart_kctest"])) { print "<p><hr>session var is set<p><hr><p>"; } $_SESSION["SES_kcart_kctest"]->hello(); ?> And a kcTest.php class which looks like: <?php class kcTest { var $foo; function kcTest() { $this->foo = "hi"; } function hello() { print "<p><hr><p>Hello, in kcTest. foo is >".$this->foo."<<p><hr><p>"; } } ?> Stick 'em both in /mod/kcart/inc and away we go. Once. Fire up a new browser and go to /index.php, and it works fine. Hit reload, and I get: Fatal error: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition kctest of the object you are trying to operate on was loaded _before_ the session was started in /home/doug/src/projects/kcart/inc/runtime.php on line 9 I've taken a look at calendar, pagemaster and rssfeeds but they don't appear to be doing anything very different to what I am. Help! Doug Rinckes |