What are some common pitfalls or mistakes to avoid when working with sessions in PHP?

One common pitfall when working with sessions in PHP is not starting the session before trying to access or modify session variables. To avoid this mistake, always call session_start() at the beginning of your script to initialize the session.

<?php
// Start the session
session_start();

// Access or modify session variables
$_SESSION['username'] = 'john_doe';
?>