What is the function of session_start() in PHP and why is it important for handling sessions?

The function session_start() in PHP is used to initialize a new session or resume an existing session. It is important for handling sessions because it allows you to store and retrieve session data across multiple pages on a website.

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

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