If you are looking to define logout functionality in Codelgniter. First we will unset the defined session variables then we will destroy the function. After this we will redirect the page in your desirable location. Please follow the below code:
// unset your session define variables
$this->session->unset_userdata('username');
$this->session->unset_userdata('loginuser');
// Destroy the session now
session_destroy();
// define your path to redirect after session destroy.
redirect('index.php/admin/index');
0 Comment(s)