I am developing and doing all the testing on a local machine using PHP Version 5.3.3-1ubuntu9.1 version. The host machine is PHP Version 5.2.15.
All the seriliaze arguments are identical.
The problems is when i try to login the user on my test local machine I do the following:
$user->getByUserId($results['id'], $db);
$_SESSION['user'] = serialize($user);
which retrieved and serialize the user and I just load it back whenever I detect that a session exists:
$user->LoadFromObject(unserialize($_SESSION['user']));
This works perfectly on my test machine. Just transfered the files on the host to see if I can get a beta version out but I keep on getting :
Warning: unserialize() expects
parameter 1 to be string, object given
in /home/gamerent/public_html/beta/includes/header.php
on line 19
i have noticed that if i echo the $_SESSION['user'] in both system the test will indeed display me the serialized one but the main one will just show me the object and will not serialize the $user.
UPDATE :
OK after some testing …..
i have seen that if i dump the session before initializing the user as
var_dump($_SESSION['user']);
$user = new User();
var_dump($_SESSION['user']);
it will display the session serialized correctly.
Exactly after that it will display the String of the sessions
My User doesnt do anything excpet init with default values
function User() {
$this->userId = 0;
$this->firstname = "Guest";
$this->password = "";
include_once('includes/generalUtils.php');
$this->generalUtils = new generalUtils();
include_once('includes/utils.php');
$this->utils = new utils();
}
You need to disable register_globals on the production machine. Otherwise you are registering a session variable by assigning to $_SESSION[‘user’]. Check these notes.