Hi,
Thanks for your quick response.
To answer your question, I am storing session data. I get this error in a login controller I have developed, and the code below handles the case if the validation was ok or not…...
if ($this->form_validation->run() == FALSE) // If login failed (is FALSE)
{
// ---------------------------------------------------- Load login view
// Load first part of template:
$data['title'] = "User login";
$this->load->view('templates/template01part1',$data);
// Load menu:
// Load second part of template:
$this->load->view('templates/template01part2',$data);
// Load body:
$this->load->view('login/login');
// Load third part of template:
$this->load->view('templates/template01part3',$data);
}
else // If login passed
{
// --------------------------------------------------------------------
//Get the username from the post of the form:
$UserName = $_POST['LoginUsername'];
// Store the username as session variable called UserName so that it can be used in other controllers:
$this->session->set_userdata('UserName', $UserName);
// --------------------------------------------------------------------
// Store the user's authentication status as Registered
$this->session->set_userdata('UserStatus', 'Registered');
// --------------------------------------------------------------------
// Store the userid as a session variable so that it can be used in other controllers
// Get the user id:
$query = $this->db->query("SELECT UserId FROM users WHERE UserName='{$UserName}' ");
// If there is at least one
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
$this->session->set_userdata('UserId', $row->UserId);
}
}
// ---------------------------------------------------- Load login success view
// Load first part of template:
$data['title'] = "Login successful!";
$this->load->view('templates/template01part1',$data);
// Menu goes here:
// Load second part of template:
$this->load->view('templates/template01part2',$data);
// Load body:
$this->load->view('login/loginsuccess');
// Load third part of template:
$this->load->view('templates/template01part3',$data);
}
I fear my code may be amateurish…............................
Thanks again for any help! (Its bedtime here so I may not respond again till the morning…...)