Jump to content

Comparing Sessions Using ||


tryingtolearn

Recommended Posts

Looking for an explanation

 

I have three different user levels and I want to grant page access depending on the level.

Say the levels are:

Level A

Level B

Level C

 

On this page I only want Levels A and B to access it

 

I have it working by checking the Session value like this

if ($_SESSION['user_level'] != 'A'){

if ($_SESSION['user_level'] != 'B'){

//redirect to the restricted page notice
}
}

 

But it wouldnt work by doing any variation on one line in the if statement??

i.e.

if (!isset($_SESSION['user_level']) || ($_SESSION['user_level'] != 'A')|| ($_SESSION['user_level'] != 'B')) {
//redirect to the restricted page notice
}

it simply redirects everyone.

 

Is there a way to get it on lne line vs. nesting the if statements - just out of curiosity.. THanks

Link to comment
https://forums.phpfreaks.com/topic/270025-comparing-sessions-using/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.