Typically such messages are passed in query parameters in the URL you redirect to. If the login page is rendered server side, the login page handler needs to then extract the message from its URL (and be sure to escape it before including it in HTML to prevent XSS exploits).
Because a message in URL is rather ugly, some choose to use cookies for this. The redirect response sets a cookie that the login page reads and immediately deletes. This approach is technically a bit flawed because it could be that another browser tab or other request could accidentally receive the cookie, instead of the tab where the user is registering.
If your login system is rather a SPA based on Javascript, possibly doing login/registration by fetch(), you may not need any redirection, as the page can maintain its state in Javascript variables or a store of the framework you are using.