Flash Messages
Let's see what flash messages are and how they can be implemented.
Creating flash messages
Most web applications use the session mainly for storing information about the logged-in user as well as information about what their access rights are.
We will talk about how that works in Authentication.
For now, let’s take a look at another popular use case for session data: flash messages.
These messages are shown to the user when they perform a certain activity or task on your website.
For instance, after submitting the contact form, the website shows a green banner saying, “Thanks for your message, we’ll be in touch soon”.
In our case, we could tell the user, “Thanks for telling us your name!”
We could do that right after we have put their name in the $_SESSION
array:
Get hands-on with 1200+ tech skills courses.