Hello,
I'm trying to get 'id' value from 'accounts' table and insert it into 'user data' column at 'ci_sessions' table. The thing is it's not working.
I have tried using: $this->session->set_userdata('id', $id); but in 'user_data' field I have inserted "id";N;
How to set id of account logged in?
This is my validate function in login controller:
PHP Code:
public function validate_credentials()
{
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if ($query) //
{
$data = array(
'name' => $this->input->post('name'),
'is_logged_in' => true
);
$this->session->set_userdata($data);
redirect('accounts/');
}
else
{
$this->index();
}
}
And here is my membership_model:
PHP Code:
class Membership_model extends CI_Model
{
function __construct()
{
parent::__construct();
}
function validate()
{
$this->db->where('name', $this->input->post('name'));
$this->db->where('password', sha1($this->input->post('password')));
$query = $this->db->get('accounts');
if($query->num_rows == 1) {
return true;
}
}
function create_account()
{
$name = $this->input->post('name');
$email = $this->input->post('email');
$new_account_insert_data = array(
'name' => $this->input->post('name'),
'password' => sha1($this->input->post('password')),
'email' => $this->input->post('email'),
'creation' => date('Y-m-d H:i:s'),
);
$insert = $this->db->insert('accounts', $new_account_insert_data);
return $this->db->insert_id();
}
Hope, someone will help me, or give me some tip, what should I do.
Thanks in advance, greetings
qeenyu