How to add the message with a redirect?

Topics from the video:

  • The session is used to transfer messages from one page to another
  • The session_start() function and $_SESSION global array variable to set messages
  • How to pass validation messages and show it inside the user register form
  • How to render errors in the form

Note: There is no Magento 2 topic discussed in the video.

Users often need to transfer messages that they receive to other people. This action can be fulfilled in two ways – "Forward" and "Redirect". While forwarding, the source message becomes an attached file and can be supplemented by additional text from the forwarding user. Redirecting is different, because the source message is not modified in any way – the final recipient gets it the same way as the one who redirects it. It is worth mentioning that if a message is forwarded, the user who forwards it (and not the initial author of the message), is indicated as its sender, whereas a redirected message is shown to the final recipient as sent by the initial sender (and not the one who redirects it). We'll explain how to recognize a redirected message later.

So, how to add a message with a redirect in Magento 2? Watch the video!