-2

如果我第一次以user1身份登录并且第二次以user2身份打开新选项卡并登录,则我在会话中遇到问题,用户 2 能够查看 user1 权限的所有页面,如何在 php 中克服这个问题?如果user2转到user1的第一个选项卡,如何显示第一个作为登录页面

   $this->is_logged_in();
        $this->clear_cache();
    }
    function is_logged_in() 
    {
        $is_logged_in = $this -> session -> userdata('is_logged_in');
        if (!isset($is_logged_in) || $is_logged_in != true)
        {
            //redirect('/www.XXXX.ae');
        }
    }
    function clear_cache()
    {
        $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, no-transform,max-age=0, post-check=0, pre-check=0");
        $this->output->set_header("Pragma: no-cache");
    }

function logout()
    {           
        $this->session->sess_destroy();
        $this->session->set_userdata('userId',"");
        $this->session->set_userdata('password',"");   
        $this->session->set_userdata('role',"");   
        $rurl = $this->session->userdata('rurl');
            redirect($rurl,'refresh');

    }

function login()
    { 
        $this->session->sess_destroy();
        $this->session->set_userdata('userId',"");
        $this->session->set_userdata('password',"");   
        $this->session->set_userdata('role',"");   
        $username   =   $this->input->post('username');
        $password   =   $this->input->post('password');
        .......
}
4

2 回答 2

1

您需要确保销毁会话 ID cookie(我假设您正在使用 cookie 来存储会话 ID)并在用户注销时取消设置 $_SESSION 超全局。

在您的问题中,登录用户是否能够在不注销的情况下直接以其他用户身份登录似乎也有点不清楚。通常在大多数应用程序中,您甚至希望在给用户一个新的登录提示之前进行特定的注销。但是,如果您的应用程序需要允许已登录用户更改登录,您还需要在登录更改时销毁会话 cookie 和变量。

于 2012-07-31T17:39:10.927 回答
-1

好的,这里的技巧是在用户登录时隐藏登录表单!那就是当我认为调用您的登录函数的 base_url() 被调用并且用户登录时,它会重定向到应用程序,而不是登录屏幕。我希望这有帮助!

于 2015-09-25T00:30:54.057 回答