What are the advantages and disadvantages of using sessions for storing object data in PHP?

When storing object data in PHP sessions, the advantage is that it allows you to persist data across multiple page loads for a specific user. However, the disadvantage is that storing large objects in sessions can consume a lot of server memory and slow down the application.

// Storing object data in PHP session
session_start();

// Create an object
$user = new stdClass();
$user->name = 'John Doe';
$user->email = 'john.doe@example.com';

// Store the object in session
$_SESSION['user'] = $user;

// Retrieve the object from session
$user = $_SESSION['user'];

// Access object properties
echo $user->name;
echo $user->email;