Lesson 22. Adding sessions and flash messages

 

In this lesson, you clean up the flow between CRUD functions by passing messages between pages to find out whether the server operations were successful or certain types of errors occurred. Currently, error messages are logged to the console, and users of the application have no way to know what they could do differently. You use sessions and cookies alongside the connect-flash package to deliver these messages to your views. By the end of the lesson, you’ll have an application that gives you a visual description of the success or failure of operations.

This lesson covers

  • Setting up sessions and cookies
  • Creating flash messages in your controller actions
  • Setting up validation middleware on incoming data
Consider this

Your recipe application is starting to collect data through the view forms you created in unit 4. Users are beginning to get frustrated, though, because they don’t know what validations you have in place, and if they fail to meet your validator expectations, they’re redirected to a different page without notice.

With some helpful packages, you can incorporate flash messaging into your application to inform your users of specific errors that occur in your application.

22.1. Setting up flash message modules

22.2. Adding flash messages to controller actions

Summary

sitemap