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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:28:26+00:00 2026-05-27T23:28:26+00:00

scenario: in-house web server running apache2, here are the virtual hosts: domain.com <– for

  • 0

scenario:
in-house web server running apache2, here are the virtual hosts:

domain.com <– for public, wordpress site

employee.domain.com <– for employees only, login required, non-wordpress site

employee visits employee.domain.com/page1.php

//page1.php
session_start();
if (isset($_SESSION['username']))

{ <page displayed here> }
else
{
$_SESSION['redir_after_auth'] = $_SERVER['PHP_SELF'];
header('Location: http://domain.com/login?sid='.session_id());
}

at domain.com/login, all $_SESSION variables are restored, then auth. continues. If successful, the employee is re-directed back to where they were trying to visit, employee.domain.com/page1.php. Now, since $_SESSION[‘username’] is set, page1.php will load.

//domain.com/login
<?php
//check for session_id (sid) and attempt to restore $_SESSION variables that were set at employees.domain.com
if (isset($_GET['sid']) && trim($_GET['sid']) != '') {
session_id($_GET['sid']);
}
session_start();
date_default_timezone_set('America/city');
$date = date('l jS F Y h:i A T');
$hostname = 'localhost';
$dbname   = 'employees'; //no, these are not the real values
$username = 'sql_username'; //no, these are not the real values
$password = 'password'; //no, these are not the real values
mysql_connect($hostname, $username, $password) or DIE('Connection to host is failed, perhaps the service is down!');
mysql_select_db($dbname) or DIE('Database name is not available!');

if(isset($_POST['username'])){
if(isset($_POST['password'])){

    $login = mysql_query("SELECT * FROM users WHERE (username = '" . mysql_real_escape_string($_POST['username']) . "') and (password = '" . mysql_real_escape_string(md5($_POST['password'])) . "')");
    $num_results = mysql_num_rows($login);


    if ($num_results == 1){
        $_SESSION['username'] = $_POST['username'];
        $_SESSION['password'] = $_POST['password'];
        while ($row = mysql_fetch_assoc($login)){
            $_SESSION['priv'] = $row['priv'];
            $_SESSION['email'] = $row['email'];
        }
        $tbl_name2="access_log";
        $user = $_POST['username'];
                    //lets record logins in mysql for later review
        $addrecord = mysql_query("INSERT INTO $tbl_name2 (id, username, date) VALUES ('','$user','$date')");
        if(isset($_SESSION['redir_after_auth'])){

            header('Location: http://employees.domain.com' . $_SESSION['redir_after_auth']);
            die();
        }
        else {
            header('Location: http://employees.domain.com?sid=' . session_id());
            unset($_SESSION['$num_results']);
            die();
        }
    }
    else {
        ?>
        <table align="center">
        <tr><td align="center">
        <p style="color:#F00">
        <?php echo 'Incorrect Username or Password'; ?>
        </p>
        </td></tr>
        </table>
        <?php
    }
}
}
?>

//this is actually a shortcode in wordpress, hence the html login form here
<div>
<form action="" method="POST">
<table align="center">
<tr><td align="left">Username: </td><td align="left"><input type="text" name="username"></td></tr>
<tr><td align="left">Password: </td><td align="left"><input type="password"         name="password"></td></tr>
<tr><td align="left"><input type="submit" value="Login"></td></tr>
</table>
</form>
</div>

There isn’t any sensative info on employees.domain.com, just company calendar, forms, ect…but, how secure is this method? It is open to the www, so I’m a bit nervous.

thought, suggestions?

thanks!

edit:

forgot to add, passwords encrypted MD5 in mysql

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

    You should have the authentication pages on employee.domain.com rather than domain.com if its only your employees you’ll be using the login functionality. From what I understand, you want your session only to be valid on employee.domain.com.
    This way the cookie (and session) set for employee.domain.com will be different from domain.com

    Also, the following code leaves scope for session fixation attacks:

    $_SESSION['redir_after_auth'] = $_SERVER['PHP_SELF'];
    header('Location: http://domain.com/login?sid='.session_id());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a typical enterprise scenario with in-house development, you might have dev, staging, and
Scenario is that we send out thousands of emails through SMTP server. Content is
Scenario: I have one subset of database and one dataware house. I have bring
Here's a classic works on my machine, but not in production scenario. ASP.NET app
We use Team Foundation Server and have numerous ASP.NET Web Application Projects. Each of
Okay, so we have a utility here in-house that generates business-model classes from our
Suppose you have an old legacy website, with an in-house php CMS. http://mysite.com/index.php?page=3&c=7 Now,
I run an in-house application, programmed with visual studio 2008, that uses SQL Server
Okay, so here's the scenario. Project A has a class library developed for it
I have a model class called House: public class House { public House() {

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.