[eluser]Unknown[/eluser]
Hallo!
I don't know if this is really a bug, but I hope I will help somebody with this.
My job runs on LAMP with PHP 5.2.6 and MySql 5.0.51b-community-nt.
Setting on application/config/config.php
Code:
$config['sess_use_database'] = TRUE;
when I try my site i have only this:
Code:
A Database Error Occurred
Error Number: 1364
Field 'user_data' doesn't have a default value
INSERT INTO `sessdata` (`session_id`, `ip_address`, `user_agent`, `last_activity`) VALUES ('f9b292089de94d6883c638705765892c', '127.0.0.1', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.', 1270279689)
To solve this I modified the method sess_create in library Session.php
Before:
Code:
function sess_create()
{
$sessid = '';
while (strlen($sessid) < 32)
{
$sessid .= mt_rand(0, mt_getrandmax());
}
// To make the session ID even more secure we'll combine it with the user's IP
$sessid .= $this->CI->input->ip_address();
$this->userdata = array(
'session_id' => md5(uniqid($sessid, TRUE)),
'ip_address' => $this->CI->input->ip_address(),
'user_agent' => substr($this->CI->input->user_agent(), 0, 50),
'last_activity' => $this->now
);
// Save the data to the DB if needed
if ($this->sess_use_database === TRUE)
{
$this->CI->db->query($this->CI->db->insert_string($this->sess_table_name, $this->userdata));
}
// Write the cookie
$this->_set_cookie();
}
After:
Code:
function sess_create()
{
$sessid = '';
while (strlen($sessid) < 32)
{
$sessid .= mt_rand(0, mt_getrandmax());
}
// To make the session ID even more secure we'll combine it with the user's IP
$sessid .= $this->CI->input->ip_address();
$this->userdata = array(
'session_id' => md5(uniqid($sessid, TRUE)),
'ip_address' => $this->CI->input->ip_address(),
'user_agent' => substr($this->CI->input->user_agent(), 0, 50),
'last_activity' => $this->now,
'user_data' => ''
);
// Save the data to the DB if needed
if ($this->sess_use_database === TRUE)
{
$this->CI->db->query($this->CI->db->insert_string($this->sess_table_name, $this->userdata));
}
// Write the cookie
$this->_set_cookie();
}
I don't like to modify the CI original code, but this works.
Does anybody have any opinion about this?
P.S.: Sorry for my english... :-(