简体   繁体   中英

session problem in php between two panels

hy I have created two panels first is members panel and second is admin panel. In these two panels, I have created a session file in those panels.

but when I logged in into members panel and without log out from this panel, I go to admin panel it does not ask any username or password it's taken me to direct index page.

members panel :

<?php
include('db.php');
session_start();

$user_check = $_SESSION['login_user'];

$ses_sql = mysqli_query($conn,"select email from outlet where email = '$user_check' ");

$row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);

$login_session = $row['email'];

if(!isset($_SESSION['login_user'])){
  header("location:login.php");
}
 ?>

Admin Panel :

<?php
include('db.php');
session_start();

$user_check = $_SESSION['login_user'];

$ses_sql = mysqli_query($conn,"select email from admin where email = '$user_check' ");

$row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);

$login_session = $row['email'];

if(!isset($_SESSION['login_user'])){
  header("location:login.php");
}
?>

You need to store admin or member flag in a session. And them apply condition on it

if($_SESSION['user_type'] == 'admin') {
    header('location:admin.php');
} else {
    header('location:member.php');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM