Which is the better route to go?
Should I store my object in session and pass it from page to page, or should I query the database each time the user migrates to another page in my web app?
If I should store my object in session, how would I go about doing that? I've tried doing it with serialize and unserialize but it is not working for me...
Thanks for any help!
EDIT: Here is some of my code
Page 1:
include "user.php";
session_start();
$user = new user();
$user->$username = "Jason";
$_SESSION["user"] = $user;
header("Location: profile.php");
Page 2:
include "user.php";
session_start();
$user = new user();
$user = $_SESSION["user"];
echo $user->$username;
No results.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…