codeigniter_tutorial
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
CodeIgniter<br />
Remove Session Data<br />
In PHP, we can remove data stored in session using the unset() function as shown<br />
below.<br />
unset($_SESSION[‘some_name’]);<br />
Removing session data in CodeIgniter is very simple as shown below. The below version<br />
of unset_userdata() function will remove only one variable from session.<br />
$this->session->unset_userdata('some_name');<br />
If you want to remove more values from session or to remove an entire array you can<br />
use the below version of unset_userdata() function.<br />
$this->session->unset_userdata($array_items);<br />
Fetch Session Data<br />
After setting data in session, we can also retrieve that data as shown below. Userdata()<br />
function will be used for this purpose. This function will return NULL if the data you are<br />
trying to access is not available.<br />
$name=$this->session->userdata('name');<br />
Example<br />
Create a controller class called Session_controller.php and save it in<br />
application/controller/Session_controller.php.<br />