[eluser]jblack199[/eluser]
Been a while since i've needed help with this codeigniter stuff but for some reason I can't wrap my head around what could be my issue...
I've got a database query that comes with the current data:
Code:
Array
(
[id] => 1
[p_id] =>
[f_name] => Name
[l_name] => Name
[nickname] => Justin
[company] =>
[affiliation] =>
[email] => email_address
[password] => encrypted_password
[contract_type] =>
[lead_program] =>
[phone] =>
[phone1] =>
[fax] =>
[address] =>
[address1] =>
[city] =>
[state] =>
[zip] =>
[country] =>
[gender] =>
[birthdate] =>
[infusionID] =>
[Specialization] =>
[SSN] =>
[TaxID] =>
[start_date] =>
[cancel_date] =>
[priority] =>
[spouse] =>
[assistant] =>
[assistant_email] =>
[last_activity] => 0000-00-00 00:00:00
[user_group] => 1
[user_status] => 1
)
What I need to do is run a foreach on this and set each thing to my userdata session...
however whenever i run:
Code:
foreach ($query->result_array() as $key => $value){
$this->session->set_userdata($key, $value);
}
all i get is something about improper use of foreach or something of the sort... but when i do:
$lata = $query->result_array();
foreach ($lata[0] as $key => $value) {
$this->session->set_userdata($key, $value);
}
it seems to work, but it doesn't actually work.
this is for 2 functions.. one is a valid_user function:
Code:
function valid_user() {
$logged = TRUE;
if ($this->session->userdata('intime') == '' && $this->uri->segment(2) != "login") {
$logged = FALSE;
}else if ($this->session->userdata('intime') < time()- 3600 && $this->uri->segment(2) != "login") {
$logged = FALSE;
} else {
$query = $this->db
->where('email', $this->session->userdata('email'))
->where('password', $this->session->userdata('password'))
->get('agents');
if ($query->num_rows() < 1) {
$logged = FALSE;
}
}
if ($logged != FALSE) {
$lata = $query->result_array();
foreach ($lata[0] as $key => $value){
$this->session->set_userdata($key, $value);
}
$this->session->set_userdata('intime', time());
$this->session->set_userdata('logged_in', TRUE);
}
return $logged;
}
and the other is the actual login function :
Code:
function letmein() {
$query = $this->db
->where('email', $this->input->post('email'))
->where("password like binary '".sha1($this->input->post('password'))."'", NULL, FALSE)
->get('agents');
if ($query->num_rows() < 1) {
$resp['msg'] = 'The email/password combination did not match.';
$resp['response'] = 'false';
$resp['type'] = 'password';
} else {
$lata = $query->result_array();
foreach ($lata[0] as $key => $value){
$this->session->set_userdata($key, $value);
}
$this->session->set_userdata('intime', time());
$this->session->set_userdata('logged_in', TRUE);
$resp['response'] = 'true';
$resp['msg'] = base_url();
}
return $resp;
}
using this code as is, it seems as though intime is never set because i never get past the login screen...