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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With