CodeIgniter Forums
Database data overwrites Session data ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Database data overwrites Session data ? (/showthread.php?tid=15602)



Database data overwrites Session data ? - El Forum - 02-09-2009

[eluser]Unknown[/eluser]
I'm trying to write some code that verifies that a user is valid and logged in by using the session library.

For this, I want to generate a random hash that is placed as part of the custom data. To verify that the user is logged in, I will proceed to compare the cookie with the db data, but I cant because the session data is overwritten by the database data on read. Therefore I have no idea what the actual cookie data was.

Line 216- Session.php
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;
                    }
                }
            }

It might be best to either remove this code or to assign it to session->dbdata