What is the best practice for storing and accessing variables in sessions in PHP?

When storing variables in sessions in PHP, it is best practice to use the `$_SESSION` superglobal array to store and access session variables. This ensures that the variables are securely stored and can be accessed across different pages within the same session. To store a variable in a session, simply assign a value to a key in the `$_SESSION` array. To access the variable later on, simply reference the key in the `$_SESSION` array.

// Start the session
session_start();

// Store a variable in the session
$_SESSION['username'] = 'john_doe';

// Access the variable from the session
$username = $_SESSION['username'];

// Output the variable
echo $username;