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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:08:35+00:00 2026-05-19T22:08:35+00:00

I am new to class development in PHP, however I am still quite confused

  • 0

I am new to class development in PHP, however I am still quite confused by the concept of sessions.

Question 1: Can sessions be changed by client manipulations? If not can I set static sessions and use them without validation?

Question 2: How should I be managing my user accounts?

I do use SALT however, a code is generated during registration and inserted into DB where it’s used for login reference. Any corrections with explanation would be much appreciated, as well anything about sessions being modified by client.

class user {
    private $username   = '';   
    private $password   = '';
    private $salt       = '';
    public  $prefix     = 'rhs_';

    function __construct () {
        $this->username = '';
        $this->password = '';
        $this->salt     = '';

        session_start();
    }

    public function login ($username, $password) {
        $mysql_conn = Database::obtain();
        $username = $mysql_conn->escape($username);
        $sql = 'SELECT `password`, `salt`, `first_name`, `last_name`, `permission` FROM `accounts` WHERE `username`="'.$username.'"';
        $row = $mysql_conn->query_first($sql);

        if(!empty($row['password'])) {
            $encrypted = md5(md5($mysql_conn->escape($password)).$row['salt']);
            if ($encrypted == $row['password']) {
                $_SESSION[$this->prefix.'username']     = $username;
                $_SESSION[$this->prefix.'password']     = $password;
                $_SESSION[$this->prefix.'name']         = $row['first_name'].' '.$row['last_name'];
                $_SESSION[$this->prefix.'permission']   = $row['permission'];
                header('location: ?page=cpanel');
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
  • 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-19T22:08:36+00:00Added an answer on May 19, 2026 at 10:08 pm

    I am new to class development in PHP

    Even if you are experienced programmer making an unsafe authentication system is easy as pie. You should be using OpenID(or systems like that like for example facebook connect) instead. They have security-experts as employees. I created a little library you can use for this. You can see a demo at http://westerveld.name/php-openid//

    Can sessions be changed by client
    manipulations? If not can I set static
    sessions and use them without
    validation?

    It can not be changed by clients, but a users session could be stolen by hackers. You need to prevent session-fixation => session_regenerate_id

    How should I be managing my user
    accounts?

    You probably should not do this, because the change you make a mistake is BIG. But below are some quick tips:

    • You should use phpass to store your password in the database. Because I did notice you are not using key stretching. You should perform a benchmark, and if you can generate hashes quickly, then you are definitely not securing your passwords safely. Bcrypt is a very good for hashing(used by phpass. You should use that library), because it is Moore’s law proof.
    • Protect your users against CSRF.
    • You should read the OWASP top 10.

    I also have created a little authentication library just for the fun of it. And I think it is pretty safe although for example logout.php is still vulnerable to CSRF although this is not really a big problem(and the fix is very easy).

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

Sidebar

Related Questions

I am new to iphone development.I have created a UIview controller class and added
Disclaimer: I'm new to web development. I can't seem to figure out what is
In my CI system\libraries directory I have a new class named DD_Controller.php. This file
I'm pretty new to php so this might be a noob question. I'm using
I am new to web development and I have been taking a class through
I am new to Joomla development and I can't seem to find any decent
New class is a subclass of the original object It needs to be php4
When I create a new class file in Flex 3 it warns me that
Whenever I write a new class and add some internal fields, I use an
I created a new class in VS. For some reason Tortoise is not picking

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.