What is the simplest way to implement sessions in PHP?

One of the simplest ways to implement sessions in PHP is by using the session_start() function at the beginning of your script. This function initializes a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie.

<?php
session_start();

// Now you can set session variables like this
$_SESSION['username'] = 'john_doe';

// And access them like this
echo $_SESSION['username'];
?>