InterviewSolution
| 1. |
Explain session in codeIgnitor. |
|
Answer» Sessions allows us to MAINTAIN the user “states” and helps to track user activity. In codeIgnitor session can be loaded with $this->load->library(‘session’); post LOADING session library object we can use with $this->session. To READ the session data : $this->session->USERDATA(‘key’). Session data can also be get by $this->session->item To create a session in codeIgnitor: Session’s Class set_userdata() method is used to create a session in CodeIgniter. This method takes an associative array containing your data that you want to add in session. To add userdata one value at a time, set_userdata() also can be use with syntax: $this->session->set_userdata('some_name', 'some_value');To REMOVE session data : It can be done with unset a particular key $this->session->unset_userdata('some_key');Unset array of item keys : $array_items = array('username', 'email'); $this->session->unset_userdata($array_items); |
|