I want to know if there is any way to define custom fields in the sessions table of CodeIgniter.
By default, CodeIgniter stores session values in the following fields:
`session_id`,
`ip_address`,
`user_agent`,
`last_activity`,
`user_data`
What if I want to store a little more information in the sessions table using cookies? I mean, if I want to add username
and want to change the field name session_id
to SessionID
.
Is it possible to achieve that without too much effort??
You can use set_userdata() function
like this
$newdata = array(
'username' => 'sudz',
'email' => 'sudz@some-site.com'
);
$this->session->set_userdata($newdata);
you can't change session_id its used by codeigniter, instead you can define your own session_id with defferent name. or you have to override the CI_Session class.