This should be simple. What am I doing wrong?
Here is the code that is failing:
$user = $_SESSION['user'];
print_r($user);
echo "Welcome " . $user->firstName;
The print_r command prints out:
__PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => User
[isLoggedIn] => 1 [lastName] => Gunn [firstName] => Scott )
But the $user->firstName method doesn't return anything. Here is the
class declaration:
<?php
class User
{
public $isLoggedIn = false;
public $lastName = "";
public $firstName = "";
}
?>
This fails after a redirect, but it's not a problem with losing the
session variables since the print_r command does print out everything
ok. However, the same code does work before the redirect (and print_r
doesn't say "Incomplete_Class" it says the correct class name). I am
redirecting to a relative path on the same server.
Here is my redirect function:
function redirect($url)
{
session_write_close();
header("Location: $url");
exit;
}
I'm pretty new to PHP so it's probably something simple. Go easy on me!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php