Page 1 of 1

Php calling a function in one class out of another

Posted: Mon May 29, 2006 11:13 am
by evolvedlight
Ok, I'm using a login system from evolt.org - its at http://evolt.org/PHP-Login-System-with-Admin-Features

Now, I have a class called Page which does various stuff including checking if they are logged in by:

Code: Select all

if($session->logged_in)
{
show logout button
}else {
show login form
}
now, I can't seem to reference this $session class from within my page class:

I can have the following on my Index Page and it will work fine

Code: Select all

if($session->logged_in)
		{
			$indexPage->WriteLoggedIn();
		} else {
			$indexPage->WriteLoginForm();
		}
However, if I have the following code within the function Make() that creates the page, it will NOT work.

Code: Select all

if($session->logged_in)
		{
			$this->WriteLoggedIn();
		} else {
			$this->WriteLoginForm();
		}

How do I get this working please?

S

Posted: Tue May 30, 2006 2:25 am
by Christopher
The problem looks like it is in the organization of your code and nothing to do with the Evolt code. You would need to show us some more code. It is not clear in what context that if() statement is being run. As $this references the current object from within its methods we would need to see that code.