Lets go over some basics of CI, we all know it’s a great php framework with a small learning curve. I am going to show you some session basics.
To use sessions make sure you have that in your auto load array. Then we can start using the session markup.
So for this example i want to add some user data that i have pulled from the database into the session. Below is how i will add custom session data.
1 2 3 4 5 6 | $SesArray = array( 'firstname' => $db_fname, 'lastname' => $db_lname ); $this->session->set_userdata($SesArray); |
Now lets say i want to retreve this data and display it. Below is how to recall this custom session data.
1 | echo $this->session->userdata('firstname'); |
The above code would display the ‘firstname’ var that was stored in the session.
Now lets remove the ‘firstname’.
1 | $this->session->unset_userdata('firstname'); |
Once that is removed from the session you will be unable to recall that again, so be sure you wish to unset it.



Leave A Comment!