Get Updated Record in Session
<p>I'm trying to store latest record updated in any user profile using session, Record is updating in Database but unable to get latest record value in session, session is showing the old value.</p>

<p>Here is the code of my controller class</p>

<pre><code>// Update Student Information
    public function model_studentupdate() {
        $studentid          = $this-&gt;db-&gt;escape($this-&gt;session-&gt;userdata('student_id'));
        $studentname        = $this-&gt;db-&gt;escape($this-&gt;input-&gt;post("name"));
        $studentcontact     = $this-&gt;db-&gt;escape($this-&gt;input-&gt;post("contact"));
        $studentcity        = $this-&gt;db-&gt;escape($this-&gt;input-&gt;post("city"));
        $studentcountry     = $this-&gt;db-&gt;escape($this-&gt;input-&gt;post("country"));

        // Update Record in User Table
        $this-&gt;db-&gt;query("UPDATE `ot4u_users` SET
        `user_name`=$studentname,
        `user_phone`=$studentcontact,
        `user_country`=$studentcountry,
        `user_city`=$studentcity
        WHERE `user_id` = $studentid");

        // Get All Records of Student
        $query  = $this-&gt;db-&gt;query("SELECT * FROM `ot4u_users` WHERE ot4u_users.user_id = $studentid");
        $query  = $query -&gt;result();

            // Store Latest Data of Tutor in Session
            $tutorSessionData = array(
            'student_id'        =&gt; $query[0]-&gt;user_id,
            'student_name'      =&gt; $query[0]-&gt;user_name,
            'student_phone'     =&gt; $query[0]-&gt;user_phone,
            'student_city'      =&gt; $query[0]-&gt;user_city,
            'student_country'   =&gt; $query[0]-&gt;user_country,
            'is_logged_in'      =&gt; true
            );
            $this-&gt;session-&gt;set_userdata($studentSessionData);
            return true;
    }
</code></pre>

<p>is there something i'm missing in code? please help </p>