How to show front end through back end

Question might be stupid however, I am curious how can I for example, after user makes an account, redirect them to the home page and display success message, however I don't want to use $_SERVER['REQUEST_URI'] since people can type paramaters in URL and get the success message.


One option is to store the value in $_SESSION https://www.php.net/manual/en/reserved.variables.session.php

This will not be editable via the end user. After log in, you could have something like:

<?php 
  if(isset($_SESSION['success_message'])){
    echo $_SESSION['success_message'];
  }
?>