View Codeigniter redirects against download

I previously used to write $this->load->view()to upload views. I noticed that there is a problem with this, especially when it comes to re-sending and the URL in the address bar. Instead, I started using redirect('controller/function','refresh')to achieve the same. My question is: is this a good approach or did he frown? I feel that my code is much smoother, but I would definitely like to know if this had side effects later.

eg. using:

$id = $this->user_model->buildAccount($name, $email);

if(isset($id) && $id != '') {
    $this->session->set_userdata('id', $id);
    redirect('users/details');
} else {
    redirect('members/');
}
+4
source share
2 answers

CI, , , , imho, . , , user/details. load->view() , . , , .

+3

PRG - Post/Redirect/Get. , .

Scenario:

, view_1 . view_1 view_2 , 2 . 1. view_2 2. view_2 -.

1: view_2 , , . " ".

2: PRG

PRG - // PRG - -, , , (view_1) β†’ Redirect β†’ Get (view_2)

Under the hood

HTTP- URL- . (, -) , , URL-, .

HTTP 1.0 HTTP 302 HTTP 1.1 HTTP- 303 ( " " ), , - , HTTP POST.

+1

All Articles