jeudi 26 novembre 2015

Codeigniter session ends after i close browser how to make remember checkbox

Codeigniter session ends after i close browser how to make remember checkbox ?

checkbox already in login form but i don't know how to do it ?

here's the login method in controller

    public function login($page = 'login') {
        if (!file_exists(APPPATH. '/views/main/' .$page. '.php')) {
            // Whoops, we don't have a page for that!

            show_404();
        }
                if($this->session->userdata('is_logged_in')) {
        redirect('home');
        $this ->session ->set_flashdata('alreadysignedin', '<div class="alert alert-info"><strong>Srroy !</strong> but you are already signed in.</div>');
    } else {
        $this ->load ->library('form_validation');
        $data['title'] = ucfirst($page); // Capitalize the first letter
        $this ->load ->model('users_model');
        $this ->load ->view('include/header', $data);
        $username = $this->input->post('username');
// Get User Role 
    $this->load->model('user_profile');
    $this->user_profile->rolesdetail($username);
    $userrole = $this->user_profile->rolesdetail($username);
// Get User Role </>
        if ($this ->input ->post('login') AND $this->form_validation ->run('login') == TRUE) {
            $data = array(
                'id'             => $userrole->id,
                'username'       => $this ->input ->post('username'),
                'is_logged_in'   => TRUE,
                'roles'          => $userrole->roles,
                'email'          => $userrole->email
            );
            $this ->session ->set_userdata($data);
            $this ->session ->set_flashdata('logindone', '<div class="alert alert-success"><strong>Congratulation!</strong> you have logged in successfully.</div>');
            redirect('home');
        }
        $this ->load ->view('main/'.$page, $data);
        $this ->load ->view('include/footer', $data);
        }
    }

i read about cookies but i did not known how it works




Aucun commentaire:

Enregistrer un commentaire