My requirement is to save the data/value into session which i am passing it to controller via url.
ex: www.pulseofpublic.com/mobile/user_profile/user_forms/1 ( 1 is the user id)
class user_login extends CI_Controller { public function user_forms($user_id) { $this->session->set_userdata('user_id',$user_id); $user_id = $this->session->userdata('user_id'); } }
After running this code and open the session table in database value for user_id is "images" instead of 1. If i write "echo "xyz";" before setting data into session using set_userdata. It is user_id=1.
class user_login extends CI_Controller { public function user_forms($user_id) { echo "xyz"; $this->session->set_userdata('user_id',$user_id); $user_id = $this->session->userdata('user_id'); } }
Why is this happening, Can some please help. I tried lot.
Please note :: session table is created in database and session library also loaded.
what is happening with out echo...
You have to do 1 thing that before making 'user_id' a session element, just clear it or remove it from session as $this->session->unset_userdata('user_id');
May be 'user_id' is already in session array as set by you. Also just print all session data as print_r($this->session->all_userdata());
I hope it will help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.