Postingan lainnya
Codeigniter : This page isn’t working localhost redirected you too many times.
ketika logout selalu redirect ke halaman login seperti gambar ini <a href=' https://goo.gl/FrhzQd '> https://goo.gl/FrhzQd </a> sudah coba hapus cookie tapi masih sama..
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class login extends CI_Controller {
function __construct(){
parent::__construct();
}
public function index(){
$id_user = $this->session->userdata("id_user");
if(!empty($id_user)){
$data["title"] = "DASHBOARD";
$data["subtitle"] = "Dashboard";
$this->load->view('/template/header', $data);
$this->load->view('/template/dashboard');
$this->load->view('/template/footer');
}else{
$this->load->view('/template/login');
}
}
public function login(){
$username = $this->input->post('username');
$password = $this->input->post('password');
$hasil = $this->mlogin->login($username,$password);
foreach ($hasil as $row) {
$id_user = $row->id_user;
$nama_user = $row->nama_user;
$email = $row->email;
$no_phone = $row->no_phone;
$username = $row->username;
$password = $row->password;
$jabatan = $row->jabatan;
}
if (empty($hasil)) {
$this->session->set_flashdata("notification","<div class='alert alert-success m-b-sm'>
<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span>
</button>
<strong>Gagal!!</strong> username dan password salah !!
</div>");
} else {
$this->session->set_userdata('id_user',$id_user);
$this->session->set_userdata('nama_user',$nama_user);
$this->session->set_userdata('email',$email);
$this->session->set_userdata('no_phone',$no_phone);
$this->session->set_userdata('username',$username);
$this->session->set_userdata('password',$password);
$this->session->set_userdata('jabatan',$jabatan);
}
redirect(base_url(), $data);
}
public function logout() {
$this->session->unset_userdata('id_user');
$this->session->unset_userdata('nama_user');
$this->session->unset_userdata('email');
$this->session->unset_userdata('no_phone');
$this->session->unset_userdata('username');
$this->session->unset_userdata('password');
$this->session->unset_userdata('jabatan');
$this->session->set_flashdata('notification', '');
$this->session->sess_destroy();
redirect(base_url());
}
}
0
2 Jawaban:
Itu Terjadi Unlimited Looping gan..,, jadi pada fungsi logout(),, yg dibuat itu kan
redirect ke base_url() .. yg otomatis nanti memanggil default controller ("login")
... nah masalahnya pada controller login pada fungsi index() ..
disitu agan kan manggil view('template/login').. nah pada view nya mungkin terdapat
logika / pengecekan jika belum login maka redirect ke controlloer "login" maka begitu
eterusnya. akan berulang2...
gambar agan gk muncul tuh.. coba cek lagi.. biar lebih jelas pertanyaannya
Semoga Membantu (^_^)
0
iya sudah cek looping pas redirect ke loginnya, tapi saya masih bingung penyebabnya kenapa..
0