Is the code below enough to secure a login area?


if ($_SESSION['logged_in']) {
    // show content for logged-in users

Note: $_SESSION['logged_in'] is just a boolean value true after validating username/pass.

Assuming you have these bases covered:

  • SSL
  • strong passwords
  • session id regeneration
  • http only
  • session fingerprint

What other ways can an attacker defeat a simple if ($_SESSION['logged_in']) flag?


1 Answer 1


if ($_SESSION['logged_in'])

This can be secure. There is no straightforward way for an attacker to modify $_SESSION or the variables within. The only way it becomes true is when your web application sets it to true.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.