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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:43:27+00:00 2026-06-17T23:43:27+00:00

I have CentOS LAMP with multiple sites. I use PHP session variable for the

  • 0

I have CentOS LAMP with multiple sites. I use PHP session variable for the log into the wesites. My problem is if you log into one site you can open another site on the same server and you will be logged in. The sites are completely separate so I want them to have to log into each separately. Each site has a different user DB.

Here are the session variables I am populating upon login.

$_SESSION["username"] = "$username";
$_SESSION["user_id"] = "$user_id";
$_SESSION["act_type"] = "$act_type";

I have created a a little sample so you can recreate the problem

There is 2 separate sites:
/var/www/html/site1
/var/www/html/site2

Each site has 2 pages index.php, secure.php
If I log into one I can open secure.php on the other site to.

/var/www/html/site1/index.php

<?php

session_start();

$user = 'jane';
$pass  = '654321';

if ( $user == $_POST[user] AND $pass == $_POST[pass] ) {

    $_SESSION[user] = $user;
    header("location: secure.php");
}
else {
    echo "Bad Login";
}

?>

<form name="form1" method="post" action="index.php">

    Username: <input name="user" type="text">
    <br />
    Password: <input name="pass" type="password">
    <br /><br />
    <input type="submit" name="Submit" value="Login">
</form>

/var/www/html/site1/secure.php

<?php

session_start();

if ( !isset($_SESSION[user]) ) {

    header("location: index.php");
}

?>
Secure Page

/var/www/html/site2/index.php

<?php

session_start();

$user = 'joe';
$pass  = '123456';

if ( $user == $_POST[user] AND $pass == $_POST[pass] ) {

    $_SESSION[user] = $user;
    header("location: secure.php");
}
else {
    echo "Bad Login";
}

?>

<form name="form1" method="post" action="index.php">

    Username: <input name="user" type="text">
    <br />
    Password: <input name="pass" type="password">
    <br /><br />
    <input type="submit" name="Submit" value="Login">
</form>

/var/www/html/site2/secure.php

<?php

session_start();

if ( !isset($_SESSION[user]) ) {

    header("location: index.php");
}

?>
Secure Page
  • 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-06-17T23:43:28+00:00Added an answer on June 17, 2026 at 11:43 pm

    I guess your having a collision between the session cookie settings. You should use either a separate php.ini file per site (if that’s possible) or a particular setup at the entry point of every site. Take a look at http://ar.php.net/manual/en/function.session-set-cookie-params.php

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

Sidebar

Related Questions

I have just installed CentOS, Apache and PHP. When I visit my site http://example.com/myapp/
I have a problem of upgrading python from 2.4 to 2.6: I have CentOS
I need some help with priviligies in centos I have a file in home/admin/public_html/generate.php
I have a clean install of a CentOs with php 5.2.13. In php.ini that
I want to run a .php file via terminal (I have CentOS), so I
I have a server with CentOs and PHP 5.3.16 and I want to enable
I have a web site hosted in a CentOS 5-Plesk-Apache server. I have recently
I have a CentOS 6 server set up with git, gitosis, nginx, and php-fpm.
I have one VPS from PowerVPS which has CentOS 5.5 (default configuration). I need
I have this code running in CentOS 5.5 ,PHP 5.1.6 ,Apache/2.2.3 ,ImageMagick 6.2.8 $convert

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.