Kashif Latif Kashif Latif - 1 year ago 33
PHP Question

Get Updated Record in Session

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.

Here is the code of my controller class

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

// Update Record in User Table
$this->db->query("UPDATE `ot4u_users` SET
WHERE `user_id` = $studentid");

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

// Store Latest Data of Tutor in Session
$tutorSessionData = array(
'student_id' => $query[0]->user_id,
'student_name' => $query[0]->user_name,
'student_phone' => $query[0]->user_phone,
'student_city' => $query[0]->user_city,
'student_country' => $query[0]->user_country,
'is_logged_in' => true
return true;

is there something i'm missing in code? please help


You have two different variables there:

$tutorSessionData = array(

should be

$studentSessionData = array(