User logout (destroy session) in Codeigniter
Paste in Controller
public function logout(){
$this->load->library('session');
$this->session->unset_userdata('ID');
$this->session->sess_destroy();
redirect('register');
}
Paste in View
<div class="site_header"><h2><a href="<?php echo base_url('index.php/Welcome/logout'); ?>">Logout</a></h2></div>
Note:- Welcome is a controller name
Comments
Post a Comment