PHP: Is it more secure/better to store user info in a class or session variable?

Method One(Class):

class User {
var $username; // User will be verified and username stored in this by another script.
// Some other code here //
}
echo "Hello, ".$class->username;
__________________________________
Method Two(Session):

session_start();
$_SESSION['username']; // User will be verified and username stored in this by another script.
echo "Hello, ".$_SESSION['username'];
 
Back
Top