0

I have an array recieved by the code

$logged_in=$this->session->userdata('logged_in');

In this I have an element gid. I want to set value in this session with gid=2. How can I set this ??

3 Answers 3

2

use set_userdata() function as follows

$this->session->set_userdata('gid', 1);

if you want to set more than one value in session, use array method as follows

$session_array = array('gid' => 2, 'name' => 'john') ;
$this->session->set_userdata($session_array);
Sign up to request clarification or add additional context in comments.

Comments

0

Using session

$this->load->library('session');
$this->session->set_userdata('gid', 2);

To get session value

echo $this->session->userdata('gid'); //Output is 2

Comments

0
    $data=array('user_name'=>$this->input->post('user_name'),
                 'user_email'=>$this->input->post('user_email'),
                 'user_password'=>md5($this->input->post('user_password')),
                 'product'=>implode(",", $this->input->post('product')),
                 'compney_name'=>$this->input->post('compney_name'),
                 'category'=>$this->input->post('category'),
                 'compney_type'=>$this->input->post('compney_type'),
                 'city'=>$this->input->post('city'),
                 'state'=>$this->input->post('state'),
                 'phone'=>$this->input->post('phone'),
                 'service_id'=>implode(",", $this->input- 
                  >post('service_id')),
                 'image'=>$this->session->userdata('images_business')
                 );
     $id = $this->session->userdata('lastid');
     $this->db->where('user_id', $id)->update('user', $data); 
     $this->session->unset_userdata('lastid');

1 Comment

Thank you for this code snippet, which might provide some immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you've made.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.