Welcome Guest, Not a member yet? Register   Sign In
Session library not freeing mysql results.
#1

[eluser]Kindari[/eluser]
I did a search and the only related posting I found was from two years ago.

in System/libraries/Session.php, in function sess_read(), the mysql results are not freed up, causing a warning on some installs.

I added on line 229 (after the block is over)
Code:
$query->free_result();
This removed the warning and I have not had any complications or unexpected results since adding it to the library. Unless this causes problems, I think it should be added to the main CodeIgniter files. Smile


EDIT:

For further clarifaction, here is the surrounding code. What I added has //MINE following it.

Code:
// Is there custom data?  If so, add it to the main session array
            $row = $query->row();
            if (isset($row->user_data) AND $row->user_data != '')
            {
                $custom_data = $this->_unserialize($row->user_data);

                if (is_array($custom_data))
                {
                    foreach ($custom_data as $key => $val)
                    {
                        $session[$key] = $val;
                    }
                }
            }
            $query->free_result(); // MINE
        }

        // Session is valid!
        $this->userdata = $session;
        unset($session);

        return TRUE;
    }




Theme © iAndrew 2016 - Forum software by © MyBB