Warum lässt die readfile-Funktion keine $_SESSION-Abfrage zu?

The readfile function in PHP does not allow direct access to session variables ($_SESSION) because it operates at a lower level than the session handling functions. To access session variables within the readfile function, you can first store the session variable in a regular variable and then use that variable in the readfile function.

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

// Store the session variable in a regular variable
$filename = $_SESSION['filename'];

// Use the regular variable in the readfile function
readfile($filename);
?>