How Sessions in Codeigniter Work How Sessions in Codeigniter Work codeigniter codeigniter

How Sessions in Codeigniter Work


Yes, is about the session id stored in the cookie. This is regenerated every 5 minutes. And when it's time to regenerate, first it will get current session data and than assign it to the new session id.

code from CI session library, function sess_update():

// Save the old session id so we know which record to// update in the database if we need it$old_sessid = $this->userdata['session_id'];$new_sessid = '';while (strlen($new_sessid) < 32){    $new_sessid .= mt_rand(0, mt_getrandmax());}// To make the session ID even more secure we'll combine it with the user's IP$new_sessid .= $this->CI->input->ip_address();// Turn it into a hash$new_sessid = md5(uniqid($new_sessid, TRUE));// Update the session data in the session data array$this->userdata['session_id'] = $new_sessid;$this->userdata['last_activity'] = $this->now;