I am testing codes from build internet which is a tutorial of OOP. I got a error message:
unserialize() expects parameter 1 to be string, object given in includes/global.inc.php on line 20
Here is the code of serialize():
$_SESSION['user'] = serialize(new User(mysql_fetch_assoc($result)));
And here is the code of unserialize():
$_SESSION['user'] = serialize(new User(mysql_fetch_assoc($result)));
I used Expert Debugger to see what's happening, I found that after user login, the page redirect to index, session variables are still correct, but after the unserialize() in index page was run, all session variables were reset to some numbers, here is the code of unserialize() line:
if(isset($_SESSION["logged_in"])) : $user = unserialize($_SESSION['user']);
I can't figure out what cause this. You can download the whole codes of the program here: http://s3.amazonaws.com/buildinternet/live-tutorials/first-php-app/first-php-application.zip