Welcome Guest, Not a member yet? Register   Sign In
Session makes no updates in the method sess_write()
#1

[eluser]mayconfsbrito[/eluser]
Hi!

I've a big problem in my application. The first page which does a insert in $CI->session->userdata doesn't update the database, but the update method of Active Record returns 1 (or true). So, my session wasn't recorded in database at the first time, but on a second attempt was recorded.

I did a test on the method sess_write() in the CI_Session class, selecting with the Active Record the record of the current session. The result shown by the Active Record was the same of updated, but when I checked at the database with PHPmyadmin, the record of this session in ci_session table wasn't upgraded.

Exemple:
Code:
function sess_write()
{

//Before userdata:  array(x:'abc')

...

$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));
//Was updated array(x:'abc',  y:'123')


echo "<pre>";
$result = $this->CI->db->query('SELECT * FROM (`ci_sessions`) WHERE `session_id` =  "' . $this->userdata['session_id'] . '"', false, true);
$result = $result->result_array();
echo "Resultado Query=";
print_r($result[0]['user_data']);
//Was printed array(x:'abc',  y:'123')
echo "</pre>";

...

//In ci_session in database was shown array(x:'abc')

}


Somebody can help me?
#2

[eluser]InsiteFX[/eluser]
You should only be updating the session user array none of the other values CI maintains them.
#3

[eluser]mayconfsbrito[/eluser]
Hi InsiteFX, I don't understand what you say. Can you explain me better?

For tests, I have inserted a sleep(1); after the update() of the session in the sess_write() function, and the system worked perfectly updating the session.

Which may be related to this?




Theme © iAndrew 2016 - Forum software by © MyBB