Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handling Errors 1

Status
Not open for further replies.

GOSCO

Technical User
Sep 26, 2000
134
GB
Im using the uflex class to handle users on an intranet im making. I want to handle users that are not logged in, which means:

$user->data['group_id'] is not set

is it appropriate to use the following code or is there a better way?

Code:
if (isset($user->data['group_id']) && $user->data['group_id'] == 0) {

{

 
for ease of coding i'd do it the other way around.

Code:
if (    !isset($user->data['group_id'])     //if the group id is not set
        || $user->data['group_id'] != 0     // OR if the group ID is set AND is not zero
  ):

   // redirect to some unauthorized page or login page etc
   die();  //expressly kill further execution
endif;

//carry on with normal page execution

you might consider encapsulating the above in a function called isLoggedIn() or similar. then it will make calling it rather simpler. of course if you use the despatch method of coding, that's not so relevant.
 
Thanks sounds like im on the right lines.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top