Hello. I am storing a serealized object in the $_SESSION[] autoglobal. I serialize it in order to avoid it bieng an incomplete function (whatever that means, that problem, as I have seen, is very poorply documented). After the user logs in, I create a new instance of the User class that holds all the information about the given user as well as few generic functions:
Code: Select all
<?php
ob_start();
//check login, etc
session_start();
$user = new User;
$_SESSION['user'] = serialize($user);
//more stuff
ob_end_flush();
?>
This is how I read the contennts of the $_SESSION['user'] object:
Code: Select all
<?php
session_start();
$user = unserialize($_SESSION['user']);
echo $user->username;
echo $user->email;
//etc..
?>
The problem is, I can only run that script once. If I go to another script and come back, or if I refresh the page, I will not see the values of the attributes of the $user object. The only way for me to see them again is to re-login. Can someone please tell me why that happens and what I can do to fix it?
Thanks!