What are the best practices for displaying user feedback messages, such as "You have successfully logged out," in PHP applications?

When displaying user feedback messages in PHP applications, it is important to ensure that the messages are clear, concise, and easily noticeable to the user. One common practice is to use session variables to store the messages and display them on the appropriate pages. This allows the messages to persist across page loads and redirects.

// Set user feedback message
$_SESSION['message'] = "You have successfully logged out";

// Display the message on the page
if(isset($_SESSION['message'])){
    echo '<div class="alert alert-success">'.$_SESSION['message'].'</div>';
    unset($_SESSION['message']); // Clear the message after displaying it
}