[eluser]allibubba[/eluser]
what i ended up with for my add to cart functionality is this:
Code:
header('location:'.$_SERVER['HTTP_REFERER']);
this works ok since you are on a product page, adding to cart just sends you back to where you were. though i think for production purposes i would facilitate the add to cart function via ajax.
as for my user redirect, which does use flash data, and seems to finally be stable:
im my user_model;
Code:
function restrictUser($role){
# does user have admin rights?
if($this->session->userdata('level') != $role){
$this->session->set_flashdata('requested_page',$this->uri->uri_string());
if($this->session->userdata('level')){
//redirect();
$this->session->set_flashdata('message','<p class="error">You do not have sufficient privileges.</p>');
redirect('user/login');
}else{
$this->session->set_flashdata('message','<p class="error">You are not logged in..</p>');
redirect('user/login');
}
}
}
and i call in my restricted controller, load my user_model, and then in the constructor:
Code:
$this->User_model->restrictUser('admin');
this checks if user is logged in and if they have admin rights. redirect is stored in flash data and passed to a redirect in my login function, i added custom messages as well to alert users to the reason they were bounced back to login.
in my login function i needed to keep the flash data alive:
Code:
$this->session->keep_flashdata('requested_page');
$this->session->keep_flashdata('message');
and on passing login, i simply bounce user back to page stored in flash data.
as for the referrer, i haven't noticed any problems.
working on creating a user library now, when i make some solid progress i'll post back. hope this helps somebody out