PHP回显整个页面(如果已验证)

dmu*_*rer -1 php security session webpage

当且仅当授予许可(即会话集)时,显示整个网页的最佳方法是什么?

<?php
    session_start();
    if(isset($_SESSION['id'])){
        echo "<html>Huge HTML Page with secret content</html>";
    }
    else {
        echo "<html>Sorry, access not granted!</html>";
Run Code Online (Sandbox Code Playgroud)

回显整个html页面对我来说似乎有点不干净,但是有什么更好的方法呢?

wil*_*ler 5

<?php
session_start();
if (! isset($_SESSION['id'])){
    header('HTTP/1.0 403 Forbidden');
    echo "Sorry, access not granted!";
    exit;
}
?>

<html>...
Run Code Online (Sandbox Code Playgroud)