Welcome Guest, Not a member yet? Register   Sign In
"user_data" value in table ci_session
#1

[eluser]Unknown[/eluser]
Hello. In CI 2.1.0 I followed the example from UserGuide - Session Class - Saving Session Data to a Database

I tried to write these data in session (like in UserGuide):

$newdata = array(
'username' => 'johndoe',
'email' => '[email protected]',
'logged_in' => TRUE
);
$this->session->set_userdata($newdata);

and I found this in table ci_session:

a:4:{s:9:"user_data";s:0:"";s:8:"username";s:7:"johndoe";s:5:"email";s:21:"[email protected]";s:9:"logged_in";b:1;}

what is this "user_data"? I ask this because this "user_data" does not appear when I used CI 2.0.3
#2

[eluser]Unknown[/eluser]
I had same issue. To fix it I use following in MY_Session:

Code:
/**
  * Create a new session
  *
  * @access public
  * @return void
  */
function sess_create()
{
  $this->userdata = array(
       'session_id' => $this->_make_sess_id(),
       'ip_address' => $this->CI->input->ip_address(),
       'user_agent' => substr($this->CI->input->user_agent(), 0, 120),
       'last_activity' => $this->now,
       'user_data'  => ''
       );


  // Save the data to the DB if needed
  //if ($this->sess_use_database === TRUE)
  //{
   $this->CI->db->set($this->userdata);
   $this->CI->db->insert($this->sess_table_name);
   //$ci_sessions_id = $this->CI->db->insert_id();
   unset($this->userdata['user_data']);
  //}

  // Write the cookie
  $this->_set_cookie();

  //if(isset($ci_sessions_id))
  //  $this->userdata['id'] = $ci_sessions_id;
}

As mentioned in previous post another option is to specify NULL instead of NOT NULL in CREATE TABLE and remove that line which wasn't in pre 2.1.0: https://github.com/kylefarris/CodeIgnite...730cf74e0c




Theme © iAndrew 2016 - Forum software by © MyBB