For some time I have been toying with the idea of creating my own forum. The concept is fairly simple, but I keep getting hung up on one feature: being able to see unread posts. Posts would be stored in a MySQL database, and I could easily make a page that shows the posts made since a user's last visit (by updating a timestamp everytime a page is accessed and comparing it with a post's timestamp), but that would only work on the first page load of the user's new visit. After that point, the user's "last activity" timestamp would be updated, and posts made after the user's previous visit which have not yet been read would no longer be displayed.
So my question is, what is the best way to keep track of individual posts that have not yet been read? I came up with several idea, such as having a field in each post's MySQL row that includes all the usernames of the users that have viewed the post, or a cookie that includes the post IDs of all the posts the user has viewed. The problem is that both of these methods are terribly inefficient (especially the first one).
Does anyone know how popular forums accomplish this task?
Any information would be helpful 🙂.
-KrazyWebGuy