How can I check if a session is set in PHP and display its contents?

To check if a session is set in PHP and display its contents, you can use the `isset()` function to check if the session variable is set and then access its contents using `$_SESSION`. If the session is set, you can display its contents by echoing out the value stored in the session variable.

session_start();

if(isset($_SESSION['your_session_variable'])) {
    echo $_SESSION['your_session_variable'];
} else {
    echo "Session variable is not set.";
}