Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter when to use redirect() and when to use $this->load->view

I am fairly new to Codeigniter and I am wondering on some Codeigniter best practices. When should i use redirect() versus using

$this->load->view

It seems that when I use redirect() then $this->session->set_flashdata works like it should but when i use

$this->load->view

the message is displayed after an additional request.

like image 750
T-Wrecks Avatar asked Nov 26 '10 00:11

T-Wrecks


1 Answers

I think you really answered your own question.

Use redirect() when a simple flash message at the top of another page is an appropriate response, use $this->load->view() when you're providing an entire page worth of feedback for whatever the incoming request may be.

So for example, when a new user signs up the "Success" page would be a loaded view and perhaps when a user edits something in their account a flash message "Changes saved" or soemthing similar on the same page is sufficient.

like image 179
fred Avatar answered Sep 28 '22 06:09

fred