Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6582371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:16:18+00:00 2026-05-25T16:16:18+00:00

ive made a login page which should assign different groups a session [‘level’] depending

  • 0

ive made a login page which should assign different groups a session [‘level’] depending on whether or not they have logged in using the correct details. say the admin logs in he gets session[‘admin’] session[‘member’] and session[‘council’] which all are dependant on his user level from the database.
but when i check the session array i get:
id, username, admin, admin, admin instead of
id, username, admin, council, member.
the code i am using for the query is

//normal user
$queryN= mysql_query("SELECT * From users where username='$username' and hashed_password ='$dash' AND
level='member' LIMIT 1");
//normal council member
 $queryC = mysql_query("SELECT * From users where username='$username' and hashed_password ='$dash' AND
level='council' LIMIT 1");
//normal admin
$queryA = mysql_query("SELECT * From users where username='$username' and hashed_password ='$dash' AND
level='admin' LIMIT 1");
//Check whether the query was successful or not      
//normal user
if(mysql_num_rows($queryN) == 1)
{session_regenerate_id();
$resultN = mysql_fetch_assoc($queryN);  
$_SESSION['user_id'] = $resultN['id'];
$_SESSION['username'] = $resultN['username'];       
$_SESSION['member'] = $resultN['level']; 
session_write_close();
redirect_to("../public/index.php");
}
//admin user
elseif(mysql_num_rows($queryA) == 1){
session_regenerate_id();
$resultA = mysql_fetch_assoc($queryA);   
$_SESSION['user_id'] = $resultA['id'];
$_SESSION['username'] = $resultA['username']; 
$_SESSION['admin'] = $resultA['level']; 
$_SESSION['member'] = $resultA['level'];
$_SESSION['council'] = $resultA['level']; 
session_write_close();
redirect_to("../public/staff.php");
}

//council user
elseif(mysql_num_rows($queryC) == 1){
session_regenerate_id();
$resultC = mysql_fetch_assoc($queryC);  
$_SESSION['user_id'] = $resultC['id'];
$_SESSION['username'] = $resultC['username'];  
$_SESSION['council'] = $resultC['level']; 
$_SESSION['member'] = $resultC['level'];
session_write_close();
redirect_to("../public/index.php");
}else{
//Login failed
redirect_to("../public/login.php");
}

and the functions to check each user credentials are:

    session_start();
    $_SESSION['ERRMSG_ARR'] = array(); 
    function logged_in() {
        return isset($_SESSION['level']);
    }

    function confirm_logged_in() {
if(!isset ($_SESSION['member']) || (trim($_SESSION['member']) == '')) {
$_SESSION['ERRMSG_ARR'][] = 'You were not Authorised to view that page';
            redirect_to("login.php");
        }
    }
function confirm_login_council() {
if(!isset ($_SESSION['council']) || (trim($_SESSION['council']) == '')) {
        $_SESSION['ERRMSG_ARR'][] = 'Sorry but you were not Authorised to view that page';
        redirect_to("login.php");
        }
    }
function confirm_login_admin(){
if(!isset($_SESSION['admin']) || (trim($_SESSION['admin']) == '')) {
    $_SESSION['ERRMSG_ARR'][] = 'Unfortunately for you; You were not Authorised to view that page';
            redirect_to("login.php");
        }
    }

and to check the session array values i used :

  foreach($_SESSION as $value){
        echo $value . " | ";
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:16:18+00:00Added an answer on May 25, 2026 at 4:16 pm

    You are setting the “admin”, “member” and “council” session variables to the same value:

    $_SESSION['admin'] = $resultA['level']; 
    $_SESSION['member'] = $resultA['level'];
    $_SESSION['council'] = $resultA['level'];
    

    Try printing with the key as well to get a clearer picture of what’s going on:

    foreach($_SESSION as $key => $value){
      echo $key, ':', $value , ' | ';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web page containing a login form which loads via HTTP, but
I have made an application which allows a user to login using their facebook
I want to skin a vb.net app I made ive googled some stuff and
I made an image to easier explain what Im after: Image Illustration http://bayimg.com/image/eabahaaci.jpg Ive
I've made many different seperate parts of a GUI system for the Nintendo DS,
I've made a class which inherits from UserControl, but which I only want to
I've made this decorator, which results in an infinite redirect loop. The problem is
I want to create a login page using Servlet & JSP. I ve created
My application is a simple login page. When it fails, I print an error
I encountered this page https://www.google.com/accounts/ServiceLogin , a Google service login page that (beyond just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.