What are some common issues beginners face when transitioning from using cookies to sessions in PHP?

One common issue beginners face when transitioning from using cookies to sessions in PHP is not properly starting the session before attempting to set or retrieve session variables. To solve this issue, make sure to call session_start() at the beginning of your PHP script.

<?php
session_start();

// Set session variable
$_SESSION['username'] = 'JohnDoe';

// Retrieve session variable
$username = $_SESSION['username'];
?>