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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:47:20+00:00 2026-05-28T05:47:20+00:00

Would it be a security risk to set the user id and pass to

  • 0

Would it be a security risk to set the user id and pass to a session? If so how?
The session vars would be in an included file. I understand that this would not allow other users, but I only have one user to log in.

****CONFIG.PHP****
session_start();
$_SESSION['USER'] = 'USERNAME';
$_SESSION['PASS'] = 'PASSWORD';


****LOGIN.PHP****
include ('config.php');
IF ($_SESSION['USER'] == $_POST['USERNAME'] && 
$_SESSION['PASS'] == $_POST['PASSWORD']){
ALLOW ACCESS;
}
  • 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-28T05:47:20+00:00Added an answer on May 28, 2026 at 5:47 am

    If you’re using server-side sessions which can’t be modified by the end-user anyways, there is no reason to store the password there. It’s just another place the password exists on your server. Once you’ve validated the it is a valid user and the password is correct, you only really need to store their user ID in the session. There’s no way they can change it, so you can always trust that it’s actually their user ID.

    There’s always the risk of session hijacking, but that’s a different topic.

    As for your code, you’re misunderstanding sessions. You set those after you’ve validated the user input.

    ****CONFIG.PHP****
    $username = 'USERNAME';
    $password = 'PASSWORD';
    
    
    ****LOGIN.PHP****
    include ('config.php');
    IF ($username == $_POST['USERNAME'] && $password == $_POST['PASSWORD']){
        session_start();
        $_SESSION['username'] = $username;
    }
    

    Then you can just test to see if $_SESSION['username'] is set. If it is, then you know you’re logged in.

    IF (isset($_SESSION['username'])){
        ALLOW ACCESS;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any security risk in allowing a user to upload an HTML file
Am wondering if there would be any security flaw in this approach. I am
When designing user table what would be the must have fields from the security/user
Would it not make sense to support a set of languages (Java, Python, Ruby,
By default, browsers don't allow cross-site AJAX requests. I understand that a badly envisioned
This sounds odd. In fact, it sounds like a security risk to me. However,
What would be the basic and obvious security considerations and recommendations in a Java
I would like to use the ASP.NET Membership Provider security framework but would like
There are many security reasons why one would want to drop an HTTP connection
I'm studying security, and I would like to know: in Windows or Unix based

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.