会员专区

Ric*_*ell 2 html php membership security session

构建仅供成员访问的页面时,以下是正确的php:

<?php if($_SESSION['logged_in']): ?>

// all code for page here

<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)

我的所有html/php都位于这两行之间吗?

还有其他方法可以做得更好吗?

我应该注意哪些安全问题?

我的内容不是特别敏感,但可能在将来.

Lig*_*ica 6

严格来说,在编写清晰的代码方面,为什么不:

<?php
if (!$_SESSION['logged_in']) {
   header("Location: login.php");
   exit;
}
?>

<!-- // all code for page here -->
Run Code Online (Sandbox Code Playgroud)

或类似的.