CodeIgniter flashdata delay CodeIgniter flashdata delay codeigniter codeigniter

CodeIgniter flashdata delay


According to the documentation flashdata exists at the next server request.

But in your case you actually set the flashdata in the same server request as you show the login view which was unsuccesful. Thats the reason it doesn't work.

A better way wuld to just allow your model method to return true or false and use that value instead. The flashdata should only be considered if you redirect the user to an error page or something like that.


As @Repox mentioned, it only works on the 'next refresh'. You are assuming that flashdata works RIGHT AWAY when you set it, but it doesn't you need an new actual page reload / refresh before that is available.

You have the right idea, but you are just using flashdata to implement your message, stick to form messages as a return result, or just a custom variable.

This is really a case of developers designing flashdata for one thing, and users using it for another.

You need to use form_error to return all form errors, don't use flashdata, it will not work as you expect it to.

Examples:http://codeigniter.com/user_guide/libraries/form_validation.html#settingerrors

You can also override any error message found in the language file. For example, to change the message for the "required" rule you will do this:

$this->form_validation->set_message('required', 'Your custom message here');