# ktor


03/22/2023, 7:39 PM
Hello guys, what is the best way to send one time data between request? Like a flash session? After a post request, i want to redirect to another page and to display a success/error message, what is the best way in ktor to redirect to another page and to pass data to it.

Casey Brooks

03/22/2023, 8:01 PM
I don’t think there’s any default “flash” API in Ktor, it’s kind of a legacy mechanism from server-rendered app frameworks, rather than a specific feature of HTTP. To my knowledge, frameworks/CMSs that have “flash” APIs basically store a value in the Session for one request, then clear the value from the session once it’s read in a subsequent request. The session can be managed either server-side or client-side in Ktor, but it would be a manual process to set and then clear that value. Since you’re doing a redirect, an easier way might be to include the “flash message” as a query parameter in the redirect URL. Then in the handler for that new URL, read the query param and display the message as appropriate. This would cause the message to still be displayed in the page if it was reloaded, while the session-based mechanism would not.


03/25/2023, 8:15 PM
@Casey Brooks thank you for your support, indeed i think that’s a good approach