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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:12:12+00:00 2026-05-24T23:12:12+00:00

I am trying to create a log in system in php. I have 3

  • 0

I am trying to create a log in system in php. I have 3 files. index.php, login.class.php (defines Login class), securePage.php.

Login class has different functions such as getUserName(), addUser(), etc.

index.php creates a new $login object, has a log in form and create a new account form.

When you create an account on the index.php page,
$login->addUser($username, $password, $first_name, $last_name, $email); function executes which creates a new account.

After you log in and hit submit, the script checks your username/password/etc and redirects you to securePage.php.

After I redirect to securePage.php from the login.class.php, I am not sure what’s the best way to check if the user has logged in correctly and have all the user’s information handy.

Right now my securePage.php creates a new login object
$login = new Login; and checks if the user has access to the page by calling checkAccess within the Login class.

// Check if the user has access to this page, otherwise redirect to login page

if($login->checkAccess()) {
   //blah blah blah
}

This is how checkAccess function looks inside Login Class

public function checkAccess() {

    // check the session access
    if(isset($_SESSION['username']) ) {
        //
        return true;
    }

}

I feel this is bad implementation because
a) I create a brand new login object and lose my data
b) I only check if the session is secure by checking if session’s username is set which can be probably faked.

What’s the best way to implement securePage.php in terms of still having all the user data and checking if the user is logged in?

  • 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-24T23:12:14+00:00Added an answer on May 24, 2026 at 11:12 pm

    Session data is server side data — it can only be faked through manually guessing PHPSESSIONID (You can read up on that here).

    The way that this is normally handled is one of two ways. If HTTP Authentication is being used (which has some major benefits, BTW), then basically every time a secure transaction needs to occur, the UN/PW have to be tested. On the other hand, if the server is storing the value (say in $_SESSION or some other framework equivalent), then the server already has the data and there is no point in re-querying.

    If you have implemented the methods __sleep and __wakeup properly, you can simply store the entire login object in $_SESSION, which would generally be my preference.

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

Sidebar

Related Questions

I'm trying to create a simple login system that will have the forms and
I am trying to create a simple log in system that uses ajax but
I am trying to create an automated log in system with cakePHP and need
I'm trying to build Facebook OAuth into my existing Authlogic login system. I have
I'm trying to create a new log file every hour with the following code
I am trying to create a rule for snort to basically log any packets
In a view I'm trying to create a new user and then log them
Ok so I am trying create a login script, here I am using PHP5
I have the below LINQ Method I am trying to create. The issue seems
I'm trying to create my first AppWidget using the AlarmManager class so that I

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.