0

I got a login file which when the user logged in checks if the user is an admin. If so it will set a value like this:

$_SESSION['isAdmin_logged_in'] = $isAdmin;

If the user is an admin this is set to true and if not to false. However, when I try to check the isset on the admin page It won't work with

if (!isset($_SESSION['isAdmin_logged_in']) == 'true') { die("Admin only"); }

Is it even possible to check an isset for a specific value?

darby
  • 127
  • 8
  • no, that is not possible - [isset](https://www.php.net/manual/en/function.isset.php) determines if a variable is declared and different from null. you can use: `if ($_SESSION['isAdmin_logged_in'] != 'true') { die("Admin only"); }` – jibsteroos Jan 22 '20 at 21:20
  • ...or break it up into 2 separate statements. Consult the duplicate. – Funk Forty Niner Jan 22 '20 at 21:21
  • I figured it out! if (!isset($_SESSION['isadmin_logged']) || $_SESSION['isadmin_logged'] != 'true') { die('Admin only area! Abmelden'); } works fine – darby Jan 22 '20 at 23:09

0 Answers0