In this episode, we kick things off by diving into how sessions work in our framework, with a major focus on flashing messages to users. Think of flash messages like those little pop-ups that tell you "You've been signed out" after you log out, which then disappear when you refresh the page.
We look at a couple of common uses for flash messages: letting users know about actions like logging out, and displaying validation errors (like when you try to log in without filling out the form). The key point is that these messages are temporary—they show once and then they're gone!
Next, we set up the session management using Symfony's session components (no extra packages needed, it's already installed). We add the session to our container so it can be accessed anywhere, then create a SessionServiceProvider to handle this.
You’ll see step-by-step how to flash a message in the logout controller ("You've been logged out"), then grab that message on the homepage controller and display it in your view. We try things out by signing in, logging out, and confirming the message appears. As expected, when the page refreshes, the message disappears, since that's how flash data works.
Finally, we cover the "manual" way of passing flash messages down to the view and rendering them with a simple conditional in the template. At the very end, we hint that in the next episode, we'll make a Twig helper to streamline this process even more, so we don't have to keep wiring things manually every time.