Jump to content

Unread Posts - Cookies Or Database?


clonetrooper9494

Recommended Posts

I see all of these "Unread" things next to topics. What I am wondering is, how do they keep track of all of every users read posts? I would think that they would use cookies to keep track of everything, but when I use IE, it still shows all of the unread posts. Which method is this forum using? If its cookies, that would be a missive cookie to have to hold every topic that the user read. If they used a database, that would also take up a lot of space and might slow down the forum. How would I set that up in a database if I wanted to have a new posts thing on my site? Would every post in the database have a column called "read_by" that would hold every user who has read the post? It seems really impractical to do it that way... but it seems to work for this forum. Which way do you think this forum is doing it? I wanted to set something like that on my site.~clone

Link to comment
Share on other sites

It is done with a database. It most likely has a table to track topic_id, user_id, and read_date.Forums usually make this a feature you can turn on/off because it can slow things down on a busy forum.

Link to comment
Share on other sites

  • 4 weeks later...

would it not be quicker to have an array of user ID's?then explode them or would this take even longer?(hi-jack alert) This is something i've become confussed when coding, to store user_id each row or in one feild and explode the values(Sorry to hi-jack, but i surpose it does relate to the topic)

Link to comment
Share on other sites

It's not a great idea to store a list of user IDs in one field because it makes searching more difficult. For example, if you're searching for ID 1, it might be in any of these:11,2,33,2,110,11,21,31So you would have to search if the field equals "1", or if it starts with "1,", or ends with ",1", or contains ",1,". If you just search for fields containing "1" it will come up with a lot of false positives. If you get each row and split it up with PHP to check, then it's going to take a (relatively) long time to search in every record.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...