Codeigniter Session

Codeigniter Session

#1 Step Set Library in Controller :

 $this->load->library(session);

Add above code in your controller method that enable to user session in your controller model and view file.

#2 Step Save value in session :

 $this->session->set_userdata(‘add_session_name_here‘,’add_session_value_here‘); 

 Set value in session using set_userdata() function, here you need to two thing required #2.1 name of session (as per your use) #2.2 Value of session (what data you want to store).

#3 Step GET value From session :

 $this->session->userdata(‘session_name_here‘); 

Get value from session using userdata() function, here you need only session name.

 

Leave a Reply

Your email address will not be published. Required fields are marked *