Passing flash messages in flask framework
Redirect with parameter: you set parameter for page1 link/form on page2 and if parameter set for page1 then show message. Good solution.
Redirect with special route: you have special route for page1 redirection from page2. It's similar to parameter.
Redirect with referer: you check http referer header to page2 for page1. Good solution, but can have issues with proxies.
Redirect with anchor: you set anchor on page2 and redirect without anchor replacing to page1, on page1 you check anchor and show message. This is best way for me when you have active ajax requests and store session in cookies. Good solution.
Store history in storage on frontend: you save page visiting or message for page1 on session storage and if page1 visited after page2 or message flag set and visited page1 then show message.
Store history in storage on backend: you save pages visiting and if page1 visited after page2 then show message.
I have a use case where, when page2 redirects user to page1, page 1 is supposed to show a flash message (e..g Your order was successfully placed). When a user visits page1 directly without being redirected from page2, I don't show any flash messages.
What is the best way to send flash_message from page2 to page1 while redirect.
Currently I am sending it as a query parameter. Page1 by default has a optional parameter, flash_message, but when user provides flash_message, it shows that flash message.
Is this how flash messages are passed between pages in flask