What are the best practices for displaying only the text that has been written since a user logged in?

When displaying only the text that has been written since a user logged in, you can achieve this by timestamping each message and storing the user's last login time. Then, when displaying messages, you can compare the message timestamp with the user's last login time to determine which messages to display.

// Assuming $messages is an array of messages with timestamps
// $userLastLogin is the timestamp of the user's last login

foreach ($messages as $message) {
    if ($message['timestamp'] > $userLastLogin) {
        echo $message['text'] . "<br>";
    }
}