How to unset session variable in codeigniter?

How to unset session variable in codeigniter?

Team Leader Asked on February 12, 2017 in CODEIGNITER.
Add Comment
2 Answer(s)

Get session data:

 $this->session->userdata('USERID');
 

To add custom session data:

$session_data = array('USERID' =>"11",'USERNAME' =>"AVIANCE",'PASSWORD' =>"12345");
 $this->session->set_userdata($session_data); // $session_data is an associative array of a USER information

To remove all session data:

 $this->session->unset_userdata('USERID'); // Removing values from session
 
Senior Developer Answered on February 12, 2017.
Add Comment
  /*unset session variable or data code */
 
 
$this ->session ->unset _userdata(‘your data’);   //unset specific key from session
 
                    $keys = array(‘data1’, ‘data2’, ‘data3’);
 
$this->session->unset_userdata($keys);     // unset multiple data at one times
Senior Developer Answered on July 2, 2018.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.