Pass object from script to script
Posted: Sun Mar 02, 2008 8:24 pm
After looking around for what seemed like forever, I can't seem to get this correct. I initialize an object on page 1 and do everything I need to do and then when I save it in a session variable and try to use that very session varible on the next page, it will not access the class anymore. If I have it echo the variable it says "Object" so I know it's passing properly.
and on page two i just try to recall the object and I can't
Any thoughts??
Code: Select all
//page 1
session_start();
include 'includes/user.php';
if(isset($_REQUEST['username']))
$username = $_REQUEST['username'];
else
header('location:index.php?error=1');
if(isset($_REQUEST["password"]))
$pass = $_REQUEST["password"];
else
header('location:index.php?error=2');
//DO SOME MYSQL GARBAGE HERE
$user = new user;
$user->id = $id; //pulled back in mysql stuff
$user->username = $username;
$_SESSION['user'] = $user;
header('location:home.php');
Code: Select all
session_start();
include "includes/user.php";
$user = $_SESSION['user'];
if(isset($_SESSION['user'])) //this returns YES
echo 'yes';
else
echo 'no';
echo $user-id; //outputs nothing