[eluser]solefald[/eluser]
My apologies if this has been asked before.... My browser (Chromium) crashes every time I try to to the forum search.
Anyway, I am working on a small project and currently trying to implement basic user management.
user logs in, and if he/she has admin permissions, they are able to add a new user. The problem, however,
is then they fill the form to add a new user and hit "Submit", their session data gets overwritten with the
data of the new user they've just added.....
Here is the login function. As you can see I am setting "loggedInAs" cookie, which is their email address:
Code:
function logMeIn()
{
$this->simpleloginsecure->login($this->input->post('user_email'), $this->input->post('password'));
$this->session->set_userdata('loggedInAs', $this->input->post('user_email'));
header('Location: /blahblah');
}
Then there is a function to validate the add user form and add info to the database (i did some changes to SimpleLoginSecure to allow me to set First name, Last name and "is_admin" y/n flag). The data gets submitted from a simple form, and i tried to change form field names not to match anything else.
Code:
function doAddUser()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('new_user_email', '"Email"', 'required');
$this->form_validation->set_rules('new_password', '"Password"', 'required|min_length[6]|matches[passconf]');
$this->form_validation->set_rules('passconf', '"Confirm Password"', 'required|min_length[6]');
if ($this->form_validation->run() == FALSE):
$this->load->view('header');
$this->load->view('user_add');
$this->load->view('footer');
else:
$this->simpleloginsecure->create($this->input->post('new_user_email'),
$this->input->post('new_password'),
$this->input->post('new_user_fname'),
$this->input->post('new_user_lname'),
$this->input->post('new_is_admin'),
$auto_login = true);
$this->load->model('db_model');
$data['data_rows'] = $this->db_model->getAll();
$this->load->view('header');
$this->load->view('user_admin', $data);
$this->load->view('footer');
endif;
This adds the user, but for some strange reason, my session data in the database gets overwritten by the data of the new user i just created.
Does anyone have any idea what is happening? Am i missing something here? Do i also have to use set_cookie() in addition to $this->session->ser_userdata( ?
Thank you!
-i