Search code examples
phpcodeigniter-2

session is not destroyed when logging out


i want session destroy logout but they don't work properly.

CONTROLLER

public function logout(){
            $this->session->ses_destroy();
            redirect('users/index');
        }

VIEW

<ul class="dropdown-menu">
   <li><a href="javascript:;">My Profile</a></li>
   <li><a href="javascript:;">My Groups</a></li>
   <li class="divider"></li>
   <li><a href="<?php echo base_url().'Users/logout' ?>">Logout</a></li>
</ul>

RESULT

Fatal error: Call to undefined method CI_Session::ses_destroy()

Solution

  • Because some spelling mistake in your controller.

    $this->session->ses_destroy(); replace $this->session->sess_destroy();
    

    read sentence properly link is : http://ellislab.com/codeigniter/user-guide/libraries/sessions.html check this link.