Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用后退按钮时重定向Codeigniter用户_Php_Codeigniter_Login - Fatal编程技术网

Php 使用后退按钮时重定向Codeigniter用户

Php 使用后退按钮时重定向Codeigniter用户,php,codeigniter,login,Php,Codeigniter,Login,如果用户在登录到my Codeigniter web应用程序后直接点击浏览器的后退按钮,他们将返回登录表单。相反,我希望用户被引导到主页 另外,当用户注销时,我想阻止访问帐户页面,但我也不知道如何做到这一点 有什么建议吗 我在下面附上了我的登录模型 控制器: class Account extends CI_Controller{ public function __construct() { parent::__construct(); $this->load->

如果用户在登录到my Codeigniter web应用程序后直接点击浏览器的后退按钮,他们将返回登录表单。相反,我希望用户被引导到主页

另外,当用户注销时,我想阻止访问帐户页面,但我也不知道如何做到这一点

有什么建议吗

我在下面附上了我的登录模型

控制器:

class Account extends CI_Controller{
public function __construct()
{
    parent::__construct();

    $this->load->model('masterentry_model');
    $this->load->model('account_model');
    // Your own constructor code
}
public function index()
{
    if($this->session->userdata('logged_in') != TRUE){//checking loged in
    $this->load->view('signin'); 
    }else{
        $data['location'] = $this->masterentry_model->getLocation();
        $data['activeUser'] = $this->masterentry_model->userActive();
        $data['flag'] = "home";
        $this->load->view('home', $data);
        //redirect('account');
    }
}

//login process
public function loginsum(){

    $this->load->library('form_validation');
    $this->form_validation->set_rules('password', 'password', 'required|callback_check_exists');

    if($this->form_validation->run() == true){
        if($this->session->userdata('logged_in') == TRUE) 
        {
            //$path =  get_redirect_path();

            redirect('account');
        }
    }
    else{
        if($this->session->userdata('logged_in') != TRUE) 
        { 
        $this->load->view('signin');
        }
        else
        {
        redirect('account');    
        }
    }
}

//check email and password with database correct or not 
public function check_exists($password){
    $email = $this->input->post('email');
    $result = $this->account_model->logincheck($email, $password);
    if($result == 0)
    {   
        $this->form_validation->set_message('check_exists', 'Email (or) Password incorrect');
        return false;
    }
    else
    {
        return true;    
    }

}

//logout process 
public function logout(){
    $session_array = array(
            'email' => "",
            'user_id' => "",
            'logged_in' => FALSE
        );

        $this->session->unset_userdata($session_array);

        $this->index();
}

}
型号:

class Account_model extends CI_Model{

 function __construct(){
    parent::__construct();
 }

 public function logincheck($email, $password){
    //echo "SELECT * FROM `account` WHERE email = '$email' AND password = '$password)'";
    $query = $this->db->query("SELECT * FROM `account` WHERE email = '$email' AND password = '".md5($password)."'");

    //checking row existes
    if($query->num_rows() == 1){
        $row = $query->row();
        $session_array = array(
            'email' => $row->email,//storing email in session 
            'user_id' => $row->id,//storing userid in session 
            'logged_in' => TRUE
        );
        $this->session->set_userdata($session_array);

        return 1;
    }else{
        return 0;
    }
  }

}

控制器的
构造函数
中包含这些标题,以防止缓存上一页

$this->output->set_header('Last-Modified:'.gmdate('D, d M Y H:i:s').'GMT');
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate');
$this->output->set_header('Cache-Control: post-check=0, pre-check=0',false);
$this->output->set_header('Pragma: no-cache');

您好,在我的注销应用程序之后,我的url像这样()在我登录之后意味着单击“上一步”按钮意味着我的url像这样()在我的应用程序注销之后。我想做一个喜欢facebook的应用程序。是的,它不工作。我的浏览器在登录后返回。注销后,它的工作。轻微的语法变化,希望澄清意图。