diff --git a/user.inc.php b/user.inc.php index 7acc5a0..f603f81 100644 --- a/user.inc.php +++ b/user.inc.php @@ -906,14 +906,16 @@ function try_login($user, $pass) /* Login successful */ return $r['id']; } + function updateSessionRoles($u=null) { if(!$u) - $u=user_load($_SESSION['user_id']); - + $u=user_load($_SESSION['users_id']); $_SESSION['roles']=array(); - foreach($u['roles'] AS $r=>$rd) { - if($rd['active']=="yes") - $_SESSION['roles'][]=$r; + if($u && is_array($u['roles'])) { + foreach($u['roles'] AS $r=>$rd) { + if($rd['active']=="yes") + $_SESSION['roles'][]=$r; + } } }