[eluser]Tim Stackhouse[/eluser]
[quote author="zEsHaN" date="1239873149"]...
After inserting data Use..
redirect('picks', 'refresh');
instead of
$this->load->view('picks');[/quote]
That's what I'm doing, however I'm not doing a meta refresh, but using a header redirect. I've done this before with PHP:
Code:
function _create($data) {
//user exists?
if($user = $this->db->_one($data['login'], "login")) {
//password OK?
if($user['password'] === md5($data['password'])) {
//set the session to the salted password hash.
$_SESSION['logged_in'] = $user['login'];
$_SESSION['name'] = $user['name'];
$salted_string = $user['password'] . SESSION_SALT;
$_SESSION['hash'] = md5($salted_string);
set_flash("notice", "You have successfully logged in.");
header("Location: /admin/");
}
else {
set_flash("notice", "Your username or password is incorrect, please try again.");
header("Location: /admin/login/");
}
}
else {
set_flash("notice", "Your username or password is incorrect, please try again");
header("Location: /admin/login/");
}
}
This correctly accepts POST data, and performs a header redirect that results in a GET request to the redirected URL.
I'm trying to get CI to do the same thing with this code:
Code:
function create() {
$email = $this->input->post('email');
$password = $this->input->post('password');
if ($session_data = $this->User->login($email, $password)) {
//success
$this->session->set_userdata('login_session',
$session_data->session_id);
redirect(site_url(''));
}
else {
//failure
$this->session->set_flashdata('message', 'Your login is invalid. Please try again.');
redirect(site_url("sessions/login"));
}
}
This results... In the correct behavior that I wanted to begin with... I just retested it and it wasn't doing this last night. At any rate, this may be something useful for people to reference.