0

I am sorry if I ask the duplicated questions. I have searched from this website already but I cannot solve my problem.

I am a newbie in PHP and I create 2 sites under the same domain like domain A = http://example.com/aaa.php domain B = http://example.com/bbb.php

These two sites using the same code. Therefore, they use the same session variable name. My problem is when I login domain A, I can use domain B without login anymore. Both sites remember the same session variable. I have tried to solve the problem by setting session_save_path() but it doesn't work.

Thank you very much for all suggestions.

loginform.php

<?php

session_start();
ini_set('session.save_path',getcwd(). '/tmp');
?>
....
if($stmt->fetch())
    {   

      $_SESSION['ssuser_name'] = $username;
      $_SESSION['ssuser_role'] = $role_id;       
      echo "<script> window.location.assign('index.php'); </script>";
    }

index.php

<?php  

 session_start(); 
 ini_set('session.save_path',getcwd(). '/tmp');
 ?>
...
if( isset($_SESSION['ssuser_name'])&&($_SESSION['ssuser_role'] == 1))
{
?>
<h4 align="right"> <a href="logout.php">Logout</a></h4>
<?php 
}else
{
?>
<h4 align="right"> <a href="loginform.php">Login</a></h4>
<?php
}   
Mod
  • 1
  • 1

0 Answers0