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 820103
In Process

The Archive Base Latest Questions

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

I am designing a web site, and it has the ability to log in.

  • 0

I am designing a web site, and it has the ability to log in. When someone is logged in, there is at times a need to know what group they’re in. Specifically, whether they are in the officer group. Currently, I have a MySQL stored proc BOOL is_officer(INT id), where id is the user id number.

My question: Is it wise to make a PHP function in my library (bool) is_officer(), which uses $_SESSION['id'] and calls the MySQL stored proc?

Next, is it wise to make a page /ajax/is_officer.php, which would call the function in PHP, which would in turn call the MySQL stored proc, in case I need to (insecurely) know whether the user is an officer on-the-fly?

(Last would be making a JS function is_officer() which would send an AJAX request to is_officer.php).

tl;dr: Same function name in many languages, one calls another, closer and closer to the database — good idea or bad idea?

I’m basically asking for your guidance here — sort of a communal yay/nay vote. Does this match any design patterns you’ve seen in the past?

  • 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-15T02:25:19+00:00Added an answer on May 15, 2026 at 2:25 am

    This seems way too specialized a function to have. With this approach, you’ll eventually accumulate a set of functions on various levels for each trivial bit of information. Also, making a roundtrip to the database can quickly become very wasteful.

    I’d prefer to store relevant information about the logged in user in a session. Something along the lines of this:

    if (/* user logged in successfully */) {
        $user = $Db->getUserInfo($id);
        // $user = array('id' => 1, 'name' => 'Foo', 'officer' => true, ...)
        $_SESSION['user'] = $user;
    }
    

    And whenever you need to know if the user is an officer, you just check for $_SESSION['user']['officer'].

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

Sidebar

Related Questions

We are designing a .net web application that has an external and internal site.
What are the topics we should pay attention while designing web site for Internet
I am designing a web site but it is behind a firewall and such
I'm re-designing a Web site and I have a problem with the existing data
I am designing a web site to use OpenId and Google is one of
I am designing an ASP.NET web application (.NET 4.0) which basically has a page
i'm designing a web site for a friend and i'm not sure what's the
I'm designing a web site where I've got a blog post and have the
Im designing a website, and often I need to present information in a nice
I am a beginner at software development and web site development. I love using

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.