codeigniter session destroy tidak berfungsi di hosting

Siang, Untuk rekan - rekan Sekolahkoding mohon izin menanyakan untuk code session di codeigniter dimana untuk proses logout dan masuk dengan login tertenu saat di localhost code berjalan tetapi saat di upload ke hosting proses logout tidak berfungsi dimana

code saya di Controller dengan nama Login


<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Login extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->load->model('crud_model');
        $this->load->database();
        $this->load->library('session');
        /* cache control */
        $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, post-check=0, pre-check=0');
        $this->output->set_header('Pragma: no-cache');
        $this->output->set_header("Expires: Mon, 26 Jul 2010 05:00:00 GMT");
    }

    //Default function, redirects to logged in user area
    public function index() {

        if ($this->session->userdata('admin_login') == 1)
            redirect(base_url() . 'index.php?admin/dashboard', 'refresh');

        else if ($this->session->userdata('doctor_login') == 1)
            redirect(base_url() . 'index.php?doctor', 'refresh');

        $this->load->view('backend/login');
    }

    //Ajax login function
    function ajax_login() {
        $response = array();

        //Recieving post input of email, password from ajax request
        $email = $_POST["email"];
        $password = $_POST["password"];
        $response['submitted_data'] = $_POST;

        //Validating login
        $login_status = $this->validate_login($email, $password);
        $response['login_status'] = $login_status;
        if ($login_status == 'success') {
            $response['redirect_url'] = $this->session->userdata('last_page');
        }

        //Replying ajax request with validation response
        echo json_encode($response);
    }

    //Validating login from ajax request
    function validate_login($email = '', $password = '') {
        $credential = array('email' => $email, 'password' => sha1($password));



        // Checking login credential for admin
        $query = $this->db->get_where('admin', $credential);
        if ($query->num_rows() > 0) {
            $row = $query->row();
            $this->session->set_userdata('admin_login', '1');
            $this->session->set_userdata('login_user_id', $row->admin_id);
            $this->session->set_userdata('name', $row->name);
            $this->session->set_userdata('login_type', 'admin');
            return 'success';
        }


        $query = $this->db->get_where('doctor', $credential);
        if ($query->num_rows() > 0) {
            $row = $query->row();
            $this->session->set_userdata('doctor_login', '1');
            $this->session->set_userdata('login_user_id', $row->doctor_id);
            $this->session->set_userdata('name', $row->name);
            $this->session->set_userdata('login_type', 'doctor');
            return 'success';
        }

        return 'invalid';
    }

    /*     * *DEFAULT NOR FOUND PAGE**** */

    function four_zero_four() {
        $this->load->view('four_zero_four');
    }

    /*     * *RESET AND SEND PASSWORD TO REQUESTED EMAIL*** */

    function reset_password() {
        $account_type = $this->input->post('account_type');
        if ($account_type == "") {
            redirect(base_url(), 'refresh');
        }
        $email = $this->input->post('email');
        $result = $this->email_model->password_reset_email($account_type, $email); //SEND EMAIL ACCOUNT OPENING EMAIL
        if ($result == true) {
            $this->session->set_flashdata('flash_message', get_phrase('password_sent'));
        } else if ($result == false) {
            $this->session->set_flashdata('flash_message', get_phrase('account_not_found'));
        }

        redirect(base_url(), 'refresh');
    }

    /*     * *****LOGOUT FUNCTION ****** */

    function logout() {
        $this->session->sess_destroy();
        $this->session->set_flashdata('logout_notification', 'logged_out');
        redirect(base_url(), 'refresh');
    }

}

di View


<li>
<a href="<?php echo base_url(); ?>index.php?login/logout">
                    Log Out <i class="entypo-logout right"></i>
</a>

Saat di Localhost XAMPP untuk code diatas berjalan lancar tetapi saat di upload ke hosting tidak bisa malah saat click logout prosesnya refresh2 trus untuk browser terimakasih

avatar rezafahmi
@rezafahmi

3 Kontribusi 0 Poin

Diperbarui 6 tahun yang lalu

5 Jawaban:

redirect langsung nama kontrollernya nda usah base url

avatar farhansyam
@farhansyam

129 Kontribusi 31 Poin

Dipost 6 tahun yang lalu

pak @farhansyam ok pak, terimakasih tetapi pas logout sudah direct ke halaman login tetapi pas mau login dengan user berbeda disini saya login dengan doctor, tampilan yang tampil masih session login admin, jadi session login admin tidak ke destroy

avatar rezafahmi
@rezafahmi

3 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

Udah cobain pake kode punya php native "session_destroy();" belum mas ? Kalau masih ngeyel di manual aja mas kaya gini $_SESSION = [];

avatar markeronly
@markeronly

378 Kontribusi 230 Poin

Dipost 6 tahun yang lalu

@markeronly belum pernah pak untuk di CI menggunakan php native "session_destroy(); atau $_SESSION = [];

avatar rezafahmi
@rezafahmi

3 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

Coba aja dulu mas kalau bisa berkabar di sini kalau gak bisa ya di sini juga hehe

avatar markeronly
@markeronly

378 Kontribusi 230 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban