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

  • SEARCH
  • Home
  • 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 8165887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:40:39+00:00 2026-06-06T19:40:39+00:00

For a user with moderator privileges; When the user logs in do i query

  • 0

For a user with moderator privileges; When the user logs in do i query to check the user is a moderator, then set a session? So on pages with moderator options , for example

if($_SESSION['mod']==1) {
//moderator options
}  

Alternatively do i put a query on everypage and check if the user is flagged as a moderator? Then for moderator options, for example

if($moderatorfound==1) {
//moderator options
}

Below, I currently set the username as a moderator in a cookie but as i am learning about PHP security this is unsafe;

    if($moderator=='1') {
    setcookie('username[3]',$moderator,time()+(60*60*24*365));  
    }

 if($_COOKIE['username'][3]==1) {
    //moderator options
    }   

What is the secure way to do this? Example would help.

  • 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-06-06T19:40:40+00:00Added an answer on June 6, 2026 at 7:40 pm

    Once the user logs in, store his information in session variables.
    No need to check with the database on every page.
    A cookie is not a good solution to hold sensitive information (such as privileges), since it might be altered by the user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assuming the following domain entity : public enum Role { User = 0, Moderator
I am dealing with special task. As a user, moderator and admin of PHPBB
User profile. I have some attributes that have only 2 or 3 options. For
USER = user PASS = pass QUERY = SELECT c1, c2, c3, c4, c5,
I have ejabberd set up using external_auth to authenticate against the user database of
Example I have 500 users and every 50 users manage by one moderator. Let's
I'm trying to use an after_create to set the default user role to subscriber.
My PHP+JS+Ajax application requires users to log in, then saves login data to $_SESSION.
as an example, i have a model Group and model User they are connected
From this MSDN Forum's answer by the moderator. To delete a row, user can

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.