Flashdata Notifications
The Flashdata Notifications library consists of a CodeIgniter library and helper to ease the creation and display of flashdata notifications. Flashdata notifications are perfect for highlighting errors and/or successes during form processing.
Usage
To create a new flashdata notification you must call the set() method of the FlashNotice class. The set() method accepts 3 parameters:
- name (default: ‘flash’): A unique name to reference this notification - used by the helper to display notifications.
- type (default: ‘error’): The type will be used as the class for the
block surrounding the notification.
- content (default: ‘An error has occurred.’): The content is the text found within the
block surrounding the notification.$this->load->library('flashnotice'); $this->flashnotice->set('login', 'error', 'Invalid username/password - please try again.');To display a notification you must call the flashnotice() function of the FlashNotice helper. Remember, a flashdata notification is only available on the next HTTP request - this is by design.
$this->load->helper('flashnotice'); echo flashnotice('login');License
This project is licensed under the GNU-LGPL with the following addendums that override, or explain in further detail, any statements found within that license:
- You may use this library as part of any commercial/derivative work.
- You are not required to license your commercial/derivative work under the GNU-LGPL.
- You are not required to provide the source code for this library if your commercial/derivative work is compiled.
- You must include an unmodified, readily available, version of this library’s readme file within all releases and derivative works.
Download
If you found this library helpful, please consider donating via Paypal.
9 Responses to “Flashdata Notifications”
- content (default: ‘An error has occurred.’): The content is the text found within the

Thanks Michael for the excellent library and tutorial!
Question: why would you use flashdata instead of the validation library for displaying form errors?
@Jonathon
Normal you would use the Validation class to display form errors, although I could see some instances in which that wouldn’t be the desired behavior (mainly really small forms that appear across any number of views).
I just implemented both errors and successes in this tutorial as added examples, not exactly as a best-usage scenario.
Thanks for the library! It sounds brilliant, but I’m not convinced of it’s usefulness.
When using a flashnotice, I still need to attempt to print out all possible flashnotices by calling there name. (right?)
I think (imho) that you should change your helper to have a single method print_notices() which would output all notices that exist in the current request.
That would make your library a real time-saver!
@Jakob
I thought about that, but I see some potential conflicts. For instance, what if a flashdata variable isn’t being used for a message to the user. For instance, it is being used to determine what class/method to return the user to after a successful login?
This could be overcome, of course, by adding in another variable that would identify the differences between flashdata set by the user and flashdata set as notifications.
It’s definitely something to put on the table for the next version and consider - thanks for the suggestion.
Definitely true, I never thought of that issue. Adding an identifier for messages would probably solve that problem though.
Looking forward to this new version! (I’m not pushing you here :P)
Hell, I got too much free time
Made a new version which does just what I wanted
Feel free to use (would be nice if you mentioned my name; but that’s not required: coding is trivial)
Grab it @ http://www.cubiso.nl/publications/michaelwales/flashdata-notificationsV2_Jakob.rar
Just made something similar for myself. A bit simplified solution without employing any libraries. You can achieve the same result using only one simple helper.
Check it out at:
http://www.cleverleap.com/flash-notice-helper/