What is the correct way to access a session variable in PHP?

To access a session variable in PHP, you can use the `$_SESSION` superglobal array. This array stores session variables that can be accessed across different pages of a website as long as the session is active. To access a specific session variable, you can use the key corresponding to that variable within the `$_SESSION` array.

// Start the session
session_start();

// Accessing a session variable named 'username'
$username = $_SESSION['username'];

// Now you can use the $username variable in your code