php - What is user_data in CodeIgniter session used to? -
when in codeigniter run var_dump($this->session->all_userdata());
prints
array (size=5) 'session_id' => string '3403084ad9f5e2582a8d9269ceb68fb7' (length=32) 'ip_address' => string '127.0.0.1' (length=9) 'user_agent' => string 'mozilla/5.0 (compatible; msie 10.0; windows nt 6.1; trident/6.0)' (length=64) 'last_activity' => int 1365456079 'user_data' => string '' (length=0)
since these automatically filled in values ci, i'm wondering if could/should overwrite user_data index, e.g 'user_data' => $username.
if ci keep update index, not work. must store session-data own indexes. experience on ci knows fixed index in session array used for. there no documentation it.
the user_data
field used session params
once want put session value use do:
$this->session->set_userdata('x','y');
the userdata('x')
stored in user_data
array key of session y
value
so user_data
key in session (or somenthing similar :d ):
'user_data' => ['x'=>'y']
so ,yes , overwrite value of user_data, setting session value need/want
more user_data field doc seems db field ci uses store session params: http://ellislab.com/codeigniter/user-guide/libraries/sessions.html
in system7libraries/session.php there no big trace of user_data
these lines:
// run update query $this->ci->db->where('session_id', $this->userdata['session_id']); $this->ci->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata));
which seems updating db field called user_data
(seems) related session db
Comments
Post a Comment