Suppose, I have a login page located at https://www.example.com/a/login.php. After successful login, user redirects to https://www.example.com/a/admin.php. I have another login page located at https://www.example.com/b/login.php and after successful login user redirects to https://www.example.com/b/admin.php. Now suppose, In a browser, a user successfully logs in to https://www.example.com/a/login.php. and redirects to admin.php page. If another user tries to access the page https://www.example.com/b/admin.php directly without login page in the same browser in another tab, then he easily bypasses the login and reaches the admin.php page. My sample code is :
login.php
<?php
          session_start();
        // if user successful login 
        $_SESSION['user_id'] = $users_id 
        // we redirect user to member page
        if (isset($_SESSION['user_id']){
        header("Location:admin.php");
        }else{
        header("Location:login.php");
        }
   ?>
admin.php
    <?php
     session_start();
    if (!isset($_SESSION['user_id']){
        header("Location:login.php");
        }
    echo "welcom user : {$_SESSION['user_id']}";
    ?>
Is there any way so that if the second user tries to access https://www.example.com/b/admin.php, in another tab of same browser, then he will be redirect to https://www.example.com/b/login.php ?
 
    