私はphp codeigniterでウェブサイトを作成しています。ログインすると、セッションが作成され、ホームページにリダイレクトされます。ログアウトすると、セッションが破棄されます。ホームページのURLを書くとうまくいきます。しかし、ブラウザの「1 ページ戻るボタン」をクリックすると、ホームページに戻ります。ホームページは、ログインしているかどうかを確認することになっていますが。私のコードを以下に示します。私のジレンマを明確に説明できれば幸いです。そうでない場合は、お尋ねください。前もって感謝します。
public function signin()
{
$this->form_validation->set_rules('email2', 'E-mail', 'required|valid_email');
$this->form_validation->set_rules('password2', 'Password', 'required|min_length[5]');
$query = "select password from user where email = '{$this->input->post('email2')}';";
if($this->form_validation->run())
{
if($this->doj_database->check_signin($query, $this->input->post('password2')))
{
$query = "select * from user where email = '{$this->input->post('email2')}';";
$data['user'] = $this->doj_database->search_with_email($query);
$newdata = array('logged_in' => TRUE);
$this->session->set_userdata($newdata);
$url = "/DIRTY_ONLINE_JUDGE/goto_home/{$data['user']['user_id']}";
redirect($url);
}
else
{
$this->load->view('wrong_login');
}
}
else
{
$this->load->view('wrong_login');
}
}
public function goto_home($id)
{
if($this->session->userdata('logged_in'))
{
$data['user'] = $this->doj_database->search_with_id($id);
$data['user']['password'] = $this->encrypt->decode($data['user']['password']);
$this->load->view('home', $data);
}
else
{
$this->load->view('not_logged_in');
}
}
public function logout()
{
$this->session->sess_destroy();
$this->load->view('index');
}